Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidFilePath indicates that a file path outside of the tree or // repository root directory was specified in the config. ErrInvalidFilePath = errors.New("invalid file path specified in config (above config root dir or source unit dir)") )
var Filename = "Srcfile"
Filename is the name of the file that configures a directory tree or repository. It is intended to be used by repository authors.
Functions ¶
This section is empty.
Types ¶
type External ¶
type External struct {
// Scanners is the default set of scanners to use. If not specified, all
// scanners in the SRCLIBPATH will be used.
Scanners []*srclib.ToolRef
}
An External configuration file, represented by this struct, can set system- and user-level settings for srclib.
func SrclibPathConfig ¶
SrclibPathConfig gets the srclib path configuration (which lists all available scanners). It reads it from SRCLIBPATH/.srclibconfig if that file exists, and otherwise it walks SRCLIBPATH for available scanners.
type Repository ¶
type Repository struct {
// URI is the repository's clone URI.
URI string `json:",omitempty"`
// Tree is the configuration for the top-level directory tree in the
// repository.
Tree
}
Repository represents the config for an entire repository.
func ReadRepository ¶
func ReadRepository(dir string, repoURI string) (*Repository, error)
ReadRepository parses and validates the configuration for a repository. If no Srcfile exists, it returns the default configuration for the repository. If an overridden configuration is specified for the repository (hard-coded in the Go code), then it is used instead of the Srcfile or the default configuration.
type Tree ¶
type Tree struct {
// SourceUnits is a list of source units in the repository, either specified
// manually in the Srcfile or discovered automatically by the scanner.
SourceUnits []*unit.SourceUnit `json:",omitempty"`
// Scanners to use to scan for source units in this tree.
Scanners []*srclib.ToolRef `json:",omitempty"`
// PreConfigCommands is a list of commands (passed to `sh -c`) that should
// be run on the tree before configuration occurs (after the initial config
// is read from the Srcfile but before scanners are run). The commands are
// run at the top-level directory of the tree.
//
// If `src config` is run with the program execution method ("-m program"),
// the commands are executed normally. If it is run with the Docker
// execution method ("-m docker"), the commands are run in a Docker
// container with the tree mounted read-write at /src. Currently this
// container runs Ubuntu 14.04 with the git, mercurial, curl, and
// build-essential packages installed.
//
// This is the only accepted way to modify the tree during processing. Tools
// shouldn't modify the tree because they run concurrently. If they run in
// Docker, they're unable to modify the tree because it is mounted
// read-only.
PreConfigCommands []string `json:",omitempty"`
// SkipDirs is a list of directory trees that are skipped. That is, any
// source units (produced by scanners) whose Dir is in a skipped dir tree is
// not processed further.
SkipDirs []string `json:",omitempty"`
// SkipUnits is a list of source units that are skipped. That is,
// any scanned source units whose name and type exactly matches a
// name and type pair in SkipUnits is skipped.
SkipUnits []struct{ Name, Type string } `json:",omitempty"`
// Config is an arbitrary key-value property map. Properties are copied
// verbatim to each source unit that is scanned in this tree.
Config map[string]interface{} `json:",omitempty"`
}
Tree represents the config for a directory and its subdirectories.
func ReadCached ¶ added in v0.0.9
func ReadCached(bdfs vfs.FileSystem) (*Tree, error)
ReadCached reads a Tree's configuration from all of its source unit definition files (which may either be in a local VFS rooted at a .srclib-cache/<COMMITID> dir, or a remote VFS). It does not read the Srcfile; the Srcfile's directives are already accounted for in the cached source unit definition files.
bdfs should be a VFS obtained from a call to (buildstore.RepoBuildStore).Commit.