Documentation ¶
Overview ¶
Package cfg handles working with the Glide configuration files.
The cfg package contains the ability to parse (unmarshal) and write (marshal) glide.yaml and glide.lock files. These files contains the details about projects managed by Glide.
To convert yaml into a cfg.Config instance use the cfg.ConfigFromYaml function. The yaml, typically in a glide.yaml file, has the following structure.
package: github.com/Masterminds/glide homepage: https://masterminds.github.io/glide license: MIT owners: - name: Matt Butcher email: technosophos@gmail.com homepage: http://technosophos.com - name: Matt Farina email: matt@mattfarina.com homepage: https://www.mattfarina.com ignore: - appengine excludeDirs: - node_modules import: - package: gopkg.in/yaml.v2 - package: github.com/Masterminds/vcs version: ^1.2.0 repo: git@github.com:Masterminds/vcs vcs: git - package: github.com/codegangsta/cli - package: github.com/Masterminds/semver version: ^1.0.0
These elements are:
- package: The top level package is the location in the GOPATH. This is used for things such as making sure an import isn't also importing the top level package.
- homepage: To find the place where you can find details about the package or applications. For example, http://k8s.io
- license: The license is either an SPDX license string or the filepath to the license. This allows automation and consumers to easily identify the license.
- owners: The owners is a list of one or more owners for the project. This can be a person or organization and is useful for things like notifying the owners of a security issue without filing a public bug.
- ignore: A list of packages for Glide to ignore importing. These are package names to ignore rather than directories.
- excludeDirs: A list of directories in the local codebase to exclude from scanning for dependencies.
- import: A list of packages to import. Each package can include:
- package: The name of the package to import and the only non-optional item.
- version: A semantic version, semantic version range, branch, tag, or commit id to use.
- repo: If the package name isn't the repo location or this is a private repository it can go here. The package will be checked out from the repo and put where the package name specifies. This allows using forks.
- vcs: A VCS to use such as git, hg, bzr, or svn. This is only needed when the type cannot be detected from the name. For example, a repo ending in .git or on GitHub can be detected to be Git. For a repo on Bitbucket we can contact the API to discover the type.
- testImport: A list of development packages not already listed under import. Each package has the same details as those listed under import.
Index ¶
- type Config
- func (c *Config) AddImport(deps ...*Dependency) error
- func (c *Config) Clone() *Config
- func (c *Config) DeDupe() error
- func (c *Config) HasDependency(name string) bool
- func (c *Config) HasExclude(ex string) bool
- func (c *Config) HasIgnore(name string) bool
- func (c *Config) Hash() (string, error)
- func (c *Config) Marshal() ([]byte, error)
- func (c *Config) MarshalYAML() (interface{}, error)
- func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error
- func (c *Config) WriteFile(glidepath string) error
- type Dependencies
- type Dependency
- func (d *Dependency) Base() string
- func (d *Dependency) Clone() *Dependency
- func (d *Dependency) GetRepo(dest string) (vcs.Repo, error)
- func (d *Dependency) HasSubpackage(sub string) bool
- func (d *Dependency) MarshalYAML() (interface{}, error)
- func (d *Dependency) Remote() string
- func (d *Dependency) UnmarshalYAML(unmarshal func(interface{}) error) error
- func (d *Dependency) Vcs() string
- type Lock
- type Lockfile
- type Locks
- type Owner
- type Owners
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Name is the name of the package or application. Name string `yaml:"package"` // Description is a short description for a package, application, or library. // This description is similar but different to a Go package description as // it is for marketing and presentation purposes rather than technical ones. Description string `json:"description,omitempty"` // Home is a url to a website for the package. Home string `yaml:"homepage,omitempty"` // License provides either a SPDX license or a path to a file containing // the license. For more information on SPDX see http://spdx.org/licenses/. // When more than one license an SPDX expression can be used. License string `yaml:"license,omitempty"` // Owners is an array of owners for a project. See the Owner type for // more detail. These can be one or more people, companies, or other // organizations. Owners Owners `yaml:"owners,omitempty"` // Ignore contains a list of packages to ignore fetching. This is useful // when walking the package tree (including packages of packages) to list // those to skip. Ignore []string `yaml:"ignore,omitempty"` // Exclude contains a list of directories in the local application to // exclude from scanning for dependencies. Exclude []string `yaml:"excludeDirs,omitempty"` // Imports contains a list of all non-development imports for a project. For // more detail on how these are captured see the Dependency type. Imports Dependencies `yaml:"import"` // DevImports contains the test or other development imports for a project. // See the Dependency type for more details on how this is recorded. DevImports Dependencies `yaml:"testImport,omitempty"` }
Config is the top-level configuration object.
func ConfigFromYaml ¶
ConfigFromYaml returns an instance of Config from YAML
func (*Config) AddImport ¶
func (c *Config) AddImport(deps ...*Dependency) error
AddImport appends dependencies to the import list, deduplicating as we go.
func (*Config) HasDependency ¶
HasDependency returns true if the given name is listed as an import or dev import.
func (*Config) HasExclude ¶
HasExclude returns true if the given name is listed on the exclude list.
func (*Config) MarshalYAML ¶
MarshalYAML is a hook for gopkg.in/yaml.v2 in the marshaling process
func (*Config) UnmarshalYAML ¶
UnmarshalYAML is a hook for gopkg.in/yaml.v2 in the unmarshalling process
type Dependencies ¶
type Dependencies []*Dependency
Dependencies is a collection of Dependency
func (Dependencies) Clone ¶
func (d Dependencies) Clone() Dependencies
Clone performs a deep clone of Dependencies
func (Dependencies) DeDupe ¶
func (d Dependencies) DeDupe() (Dependencies, error)
DeDupe cleans up duplicates on a list of dependencies.
func (Dependencies) Get ¶
func (d Dependencies) Get(name string) *Dependency
Get a dependency by name
func (Dependencies) Has ¶
func (d Dependencies) Has(name string) bool
Has checks if a dependency is on a list of dependencies such as import or testImport
func (Dependencies) Remove ¶
func (d Dependencies) Remove(name string) Dependencies
Remove removes a dependency from a list of dependencies
type Dependency ¶
type Dependency struct { Name string `yaml:"package"` Reference string `yaml:"version,omitempty"` Pin string `yaml:"-"` Repository string `yaml:"repo,omitempty"` VcsType string `yaml:"vcs,omitempty"` Subpackages []string `yaml:"subpackages,omitempty"` Arch []string `yaml:"arch,omitempty"` Os []string `yaml:"os,omitempty"` }
Dependency describes a package that the present package depends upon.
func DependencyFromLock ¶
func DependencyFromLock(lock *Lock) *Dependency
DependencyFromLock converts a Lock to a Dependency
func (*Dependency) Base ¶
func (d *Dependency) Base() string
func (*Dependency) Clone ¶
func (d *Dependency) Clone() *Dependency
Clone creates a clone of a Dependency
func (*Dependency) GetRepo ¶
func (d *Dependency) GetRepo(dest string) (vcs.Repo, error)
GetRepo retrieves a Masterminds/vcs repo object configured for the root of the package being retrieved.
func (*Dependency) HasSubpackage ¶
func (d *Dependency) HasSubpackage(sub string) bool
HasSubpackage returns if the subpackage is present on the dependency
func (*Dependency) MarshalYAML ¶
func (d *Dependency) MarshalYAML() (interface{}, error)
MarshalYAML is a hook for gopkg.in/yaml.v2 in the marshaling process
func (*Dependency) Remote ¶
func (d *Dependency) Remote() string
Remote returns the remote location to fetch source from. This location is the central place where mirrors can alter the location.
func (*Dependency) UnmarshalYAML ¶
func (d *Dependency) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML is a hook for gopkg.in/yaml.v2 in the unmarshaling process
func (*Dependency) Vcs ¶
func (d *Dependency) Vcs() string
Vcs returns the VCS type to fetch source from.
type Lock ¶
type Lock struct { Name string `yaml:"name"` Version string `yaml:"version"` Repository string `yaml:"repo,omitempty"` VcsType string `yaml:"vcs,omitempty"` Subpackages []string `yaml:"subpackages,omitempty"` Arch []string `yaml:"arch,omitempty"` Os []string `yaml:"os,omitempty"` }
Lock represents an individual locked dependency.
func LockFromDependency ¶
func LockFromDependency(dep *Dependency) *Lock
LockFromDependency converts a Dependency to a Lock
type Lockfile ¶
type Lockfile struct { Hash string `yaml:"hash"` Updated time.Time `yaml:"updated"` Imports Locks `yaml:"imports"` DevImports Locks `yaml:"testImports"` }
Lockfile represents a glide.lock file.
func LockfileFromMap ¶
func LockfileFromMap(ds map[string]*Dependency, hash string) *Lockfile
LockfileFromMap takes a map of dependencies and generates a lock Lockfile instance.
func LockfileFromYaml ¶
LockfileFromYaml returns an instance of Lockfile from YAML
func NewLockfile ¶
func NewLockfile(ds, tds Dependencies, hash string) (*Lockfile, error)
NewLockfile is used to create an instance of Lockfile.
func ReadLockFile ¶
ReadLockFile loads the contents of a glide.lock file.
func (*Lockfile) Fingerprint ¶
Fingerprint returns a hash of the contents minus the date. This allows for two lockfiles to be compared irrespective of their updated times.
func (*Lockfile) MarshalYAML ¶
MarshalYAML is a hook for gopkg.in/yaml.v2. It sorts import subpackages lexicographically for reproducibility.
type Locks ¶
type Locks []*Lock
Locks is a slice of locked dependencies.
func (Locks) Len ¶
Len returns the length of the Locks. This is needed for sorting with the sort package.
type Owner ¶
type Owner struct { // Name describes the name of an organization. Name string `yaml:"name,omitempty"` // Email is an email address to reach the owner at. Email string `yaml:"email,omitempty"` // Home is a url to a website for the owner. Home string `yaml:"homepage,omitempty"` }
Owner describes an owner of a package. This can be a person, company, or other organization. This is useful if someone needs to contact the owner of a package to address things like a security issue.