cfg

package
v0.0.0-...-2eab91f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 18, 2016 License: MIT Imports: 10 Imported by: 0

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
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.
  • 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.
  • devImport: A list of development packages. Each package has the same details as those listed under import.

Index

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"`

	// 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:"devimport,omitempty"`
}

Config is the top-level configuration object.

func ConfigFromYaml

func ConfigFromYaml(yml []byte) (*Config, error)

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) Clone

func (c *Config) Clone() *Config

Clone performs a deep clone of the Config instance

func (*Config) DeDupe

func (c *Config) DeDupe() error

DeDupe consolidates duplicate dependencies on a Config instance

func (*Config) HasDependency

func (c *Config) HasDependency(name string) bool

HasDependency returns true if the given name is listed as an import or dev import.

func (*Config) HasIgnore

func (c *Config) HasIgnore(name string) bool

HasIgnore returns true if the given name is listed on the ignore list.

func (*Config) Hash

func (c *Config) Hash() (string, error)

Hash generates a sha256 hash for a given Config

func (*Config) Marshal

func (c *Config) Marshal() ([]byte, error)

Marshal converts a Config instance to YAML

func (*Config) MarshalYAML

func (c *Config) MarshalYAML() (interface{}, error)

MarshalYAML is a hook for gopkg.in/yaml.v2 in the marshaling process

func (*Config) UnmarshalYAML

func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is a hook for gopkg.in/yaml.v2 in the unmarshalling process

func (*Config) WriteFile

func (c *Config) WriteFile(glidepath string) error

WriteFile writes a Glide YAML file.

This is a convenience function that marshals the YAML and then writes it to the given file. If the file exists, it will be clobbered.

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

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"`
	UpdateAsVendored bool     `yaml:"-"`
}

Dependency describes a package that the present package depends upon.

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) UnmarshalYAML

func (d *Dependency) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is a hook for gopkg.in/yaml.v2 in the unmarshaling process

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.

type Lockfile

type Lockfile struct {
	Hash       string    `yaml:"hash"`
	Updated    time.Time `yaml:"updated"`
	Imports    Locks     `yaml:"imports"`
	DevImports Locks     `yaml:"devImports"`
}

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

func LockfileFromYaml(yml []byte) (*Lockfile, error)

LockfileFromYaml returns an instance of Lockfile from YAML

func NewLockfile

func NewLockfile(ds Dependencies, hash string) *Lockfile

NewLockfile is used to create an instance of Lockfile.

func (*Lockfile) Marshal

func (lf *Lockfile) Marshal() ([]byte, error)

Marshal converts a Config instance to YAML

func (*Lockfile) WriteFile

func (lf *Lockfile) WriteFile(lockpath string) error

WriteFile writes a Glide lock file.

This is a convenience function that marshals the YAML and then writes it to the given file. If the file exists, it will be clobbered.

type Locks

type Locks []*Lock

Locks is a slice of locked dependencies.

func (Locks) Len

func (l Locks) Len() int

Len returns the length of the Locks. This is needed for sorting with the sort package.

func (Locks) Less

func (l Locks) Less(i, j int) bool

Less is needed for the sort interface. It compares two locks based on their name.

func (Locks) Swap

func (l Locks) Swap(i, j int)

Swap is needed for the sort interface. It swaps the position of two locks.

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.

func (*Owner) Clone

func (o *Owner) Clone() *Owner

Clone creates a clone of a Dependency

type Owners

type Owners []*Owner

Owners is a list of owners for a project.

func (Owners) Clone

func (o Owners) Clone() Owners

Clone performs a deep clone of Owners

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL