Documentation
¶
Overview ¶
Package dirmd implements parsing and transformations of directory metadata.
Index ¶
- Constants
- func Merge(dst, src *dirmdpb.Metadata)
- func MigrateMetadata(dir string) error
- func ReadFile(fileName string) (*dirmdpb.Metadata, error)
- func ReadMetadata(dir string) (*dirmdpb.Metadata, error)
- func ReadOwners(dir string) (md *dirmdpb.Metadata, ignored []string, err error)
- func ToLocationTags(mapping *Mapping) (*sinkpb.LocationTags_Repo, error)
- func ValidateFile(fileName string) error
- type Mapping
Constants ¶
const Filename = "DIR_METADATA"
Filename is the standard name of the metadata file.
const OwnersFilename = "OWNERS"
OwnersFilename is the filename for OWNERS files.
Variables ¶
This section is empty.
Functions ¶
func Merge ¶
Merge merges metadata from src to dst. Does nothing if src is nil.
The current implementation is just proto.Merge, but it may change in the future.
func MigrateMetadata ¶
MigrateMetadata moves metadata from legacy OWNERS of the given directory into DIR_METADATA file.
func ReadMetadata ¶
ReadMetadata reads metadata from a single directory. See also ReadMapping.
Returns (nil, nil) if the metadata is not defined.
func ReadOwners ¶
ReadOwners reads metadata from legacy OWNERS of the given directory and returns a dirmdpb.Metadata message along with the lines that were ignored. Returns (nil, nil, nil) if OWNERS file does not exist.
func ToLocationTags ¶
func ToLocationTags(mapping *Mapping) (*sinkpb.LocationTags_Repo, error)
ToLocationTags converts all dir metadata to test location tags.
func ValidateFile ¶
ValidateFile returns a non-nil error if the metadata file is invalid.
A valid file has a base filename "DIR_METADATA" or "OWNERS". The format of its contents correspond to the base name.
Types ¶
type Mapping ¶
Mapping is a mapping from a directory to its metadata.
It wraps the corresponding protobuf message and adds utility functions.
func ReadMapping ¶
ReadMapping reads all metadata from files in git in the given directories.
Each directory must reside in a git checkout. One of the repos must be the root repo, while other repos must be its sub-repos. In other words, all git repos referred to by the directories must be subdirectories of one of the repos. The root dir of the root repo becomes the metadata root.
Unless the form is sparse, the returned mapping includes metadata of ancestors and descendants of the specified directories. In the sparse form, metadata of only the specified directories is returned, which is usually much faster.
Descendants of the specified directories are discovered using "git ls-files <dir>" and not FS walk. This means files outside of the repo are ignored, as well as files matched by .gitignore files. Note that when reading ancestors of the specified directories, the .gitignore files are not respected. This inconsistency should not make a difference in the vast majority of cases because it is confusing to have git-ignored DIR_METADATA in the middle of the ancestry chain. Such a case might indicate that DIR_METADATA files are used incorrectly. This behavior can be changed, but it would come with a performance penalty.
func (*Mapping) ComputeAll ¶
ComputeAll computes full metadata for each dir.