Documentation ¶
Index ¶
- Constants
- type Configuration
- type Filter
- type Graph
- func (g Graph) DependenciesOf(node string) []string
- func (g Graph) Filter(filter Filter) (*Graph, error)
- func (g Graph) Nodes() (nodes []string, err error)
- func (g Graph) NodesByName(name string) (pkgs []Package, err error)
- func (g Graph) Packages() []string
- func (g Graph) ReverseSorted() ([]Package, error)
- func (g Graph) Sorted() ([]Package, error)
- func (g Graph) SubgraphWithLeaves(leaves []string) (*Graph, error)
- func (g Graph) SubgraphWithRoots(roots []string) (*Graph, error)
- type GraphOptions
- type Package
- type Packages
- func (p Packages) Config(name string, packageOnly bool) []*Configuration
- func (p Packages) ConfigByKey(key string) *Configuration
- func (p Packages) Name() string
- func (p Packages) PackageNames() []string
- func (p Packages) Packages() []*Configuration
- func (p Packages) PkgInfo(pkgName string) (*config.Package, error)
- func (p Packages) Repository(arch string) apk.NamedIndex
- func (p Packages) Source() string
- func (p Packages) Sub(names ...string) (*Packages, error)
Constants ¶
const (
Local = "local"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Configuration ¶
type Configuration struct { *config.Configuration Path string // contains filtered or unexported fields }
Configuration represents a configuration along with the file that sourced it. It can be for an origin package, a subpackage, or something that is provided by a package. The Configuration field is a pointer to the actual configuration as parsed from a file. The Path field is the path to the file from which the configuration was parsed. The Name and Version fields are the name and version of the package, subpackage, or provided item. In the case of an origin package, the Name field is the same as the Configuration.Package.Name field, and the Version field is the same as the Configuration.Package.Version field with the epoch added as `-r<epoch>`. In the case of a subpackage or provided item, the Name and Version fields may be different.
func (Configuration) Name ¶
func (c Configuration) Name() string
func (Configuration) Resolved ¶
func (c Configuration) Resolved() bool
func (Configuration) Source ¶
func (c Configuration) Source() string
func (Configuration) String ¶
func (c Configuration) String() string
func (Configuration) Version ¶
func (c Configuration) Version() string
type Filter ¶
Filter is a function that takes a Package and returns true if the Package should be included in the filtered Graph, or false if it should be excluded.
func FilterLocal ¶
func FilterLocal() Filter
FilterLocal returns a Filter that returns true if the Package's source matches the local source, or false otherwise.
func FilterNotLocal ¶
func FilterNotLocal() Filter
FilterNotLocal returns a Filter that returns true if the Package's source matches the local source, or false otherwise.
func FilterNotSources ¶
FilterNotSources returns a Filter that returns false if the Package's source matches one of the provided sources, or true otherwise
func FilterSources ¶
FilterSources returns a Filter that returns true if the Package's source matches one of the provided sources, or false otherwise
type Graph ¶
Graph represents an interdependent set of packages defined in one or more Melange configurations, as defined in Packages, as well as upstream repositories and their package indexes, as declared in those configurations files. The graph is directed and acyclic.
func NewGraph ¶
func NewGraph(pkgs *Packages, options ...GraphOptions) (*Graph, error)
NewGraph returns a new Graph using the packages, including names and versions, in the Packages struct. It parses the packages to create the dependency graph. If the list of packages creates a cycle, an error is returned. If a package cannot be resolved, an error is returned, unless WithAllowUnresolved is set.
func (Graph) DependenciesOf ¶
DependenciesOf returns a slice of the names of the given package's dependencies, sorted alphabetically.
func (Graph) Filter ¶
Filter returns a new Graph that's a subgraph of g, where the set of nodes in the new graph are filtered by the provided parameters. Must provide a func to which each Vertex of type Package is processed, and should return true to keep the Vertex and all references to it, or false to remove the Vertex and all references to it. Some convenience functions are provided for common filtering needs.
func (Graph) Nodes ¶
Nodes returns a slice of all of the nodes in the graph, sorted alphabetically. Unlike Packages, this includes subpackages, provides, etc.
func (Graph) NodesByName ¶
NodesByName returns a slice of all of the nodes in the graph for which the Vertex's Name() matches the provided name. The sorting order is not guaranteed.
func (Graph) Packages ¶
Packages returns a slice of the names of all origin packages, sorted alphabetically.
func (Graph) ReverseSorted ¶
ReverseSorted returns a list of all package names in the Graph, sorted in reverse topological order, meaning that packages later in the list depend on packages earlier in the list.
func (Graph) Sorted ¶
Sorted returns a list of all package names in the Graph, sorted in topological order, meaning that packages earlier in the list depend on packages later in the list.
func (Graph) SubgraphWithLeaves ¶
SubgraphWithLeaves returns a new Graph that's a subgraph of g, where the set of the new Graph's leaves will be identical to or a subset of the given set of leaves.
In other words, the new subgraph will contain all packages (transitively) that are dependent on the packages whose names were given as the `leaves` argument.
func (Graph) SubgraphWithRoots ¶
SubgraphWithRoots returns a new Graph that's a subgraph of g, where the set of the new Graph's roots will be identical to or a subset of the given set of roots.
In other words, the new subgraph will contain all dependencies (transitively) of all packages whose names were given as the `roots` argument.
type GraphOptions ¶
type GraphOptions func(*graphOptions) error
func WithAllowUnresolved ¶
func WithAllowUnresolved() GraphOptions
func WithBuildtimeReposRuntime ¶
func WithBuildtimeReposRuntime(use bool) GraphOptions
WithBuildtimeReposRuntime add any repos and keys used for buildtime resolution at runtime. If this is set to true, all buildtime repositories and keys, i.e. those defined in environments.contents.repositories and environments.contents.keys, will be used for runtime resolution as well, i.e. package.dependencies.runtime.
func WithKeys ¶
func WithKeys(keys ...string) GraphOptions
WithKeys add keys for validating repositories referenced in the buildtime graph, i.e. environments.contents.packages. The local repository in which this package is defined does not need additional keys. Normally used in concert with WithRepos.
func WithRepos ¶
func WithRepos(repos ...string) GraphOptions
WithRepos add repos for resolution of the buildtime graph, i.e. environments.contents.packages. Always includes packages in the local repository in which this package is defined. Optionally, you can add other repositories.
func WithRuntimeKeys ¶
func WithRuntimeKeys(keys ...string) GraphOptions
WithRuntimeKeys add keys for validating repositories referenced in the runtime graph, i.e. package.dependencies.runtime. The local repository in which this package is defined does not need additional keys. Normally used in concert with WithRuntimeRepos.
func WithRuntimeRepos ¶
func WithRuntimeRepos(repos ...string) GraphOptions
WithRuntimeRepos add repos for resolution of the runtime graph, i.e. package.dependencies.runtime. Always includes packages in the local repository in which this package is defined. Optionally, you can add other repositories.
type Package ¶
type Package interface { Name() string Version() string String() string // String shows the combination name and version Source() string // Source shows the source repository of the package Resolved() bool // if this is resolved or just an interim }
Package represents an individual package.
type Packages ¶
type Packages struct {
// contains filtered or unexported fields
}
Packages represents a set of package configurations, including the parent, or origin, package, its subpackages, and whatever else it 'provides'. It contains references from each such origin package, subpackage and provides to the origin config.
It also maintains a list of the origin packages.
It does not try to determine relationships and dependencies between packages. For that, pass a Packages to NewGraph.
func NewPackages ¶
NewPackages reads an fs.FS to get all of the Melange configuration yamls in the given directory, and then parses them, including their subpackages and 'provides' parameters, to create a Packages struct with all of the information, as well as the list of original packages, and, for each such package, the source path (yaml) from which it came. The result is a Packages struct.
The input is any fs.FS filesystem implementation. Given a directory path, you can call NewPackages like this:
NewPackages(os.DirFS("/path/to/dir"), "/path/to/dir")
The repetition of the path is necessary because of how the upstream parser in melange requires the full path to the directory to be passed in.
func (Packages) Config ¶
func (p Packages) Config(name string, packageOnly bool) []*Configuration
Config returns the Melange configuration for the package, provides or subpackage with the given name, if the package is present in the Graph. If it's not present, Config returns an empty list. Pass packageOnly=true to restruct it just to origin package names.
func (Packages) ConfigByKey ¶
func (p Packages) ConfigByKey(key string) *Configuration
func (Packages) PackageNames ¶
Packages returns a slice of the names of all packages, sorted alphabetically.
func (Packages) Packages ¶
func (p Packages) Packages() []*Configuration
Packages returns a slice of every package and subpackage available in the Packages struct, sorted alphabetically and then by version, with each package converted to a *repository.RepositoryPackage.
func (Packages) PkgInfo ¶
PkgInfo returns the build.Package struct for a given package name. If no such package name is found in the packages, return nil package and nil error.
func (Packages) Repository ¶
func (p Packages) Repository(arch string) apk.NamedIndex
Repository provide the Packages as a repository.RepositoryWithIndex. To be used in other places that require using alpine/go structs instead of ours.
func (Packages) Sub ¶
Sub returns a new Packages whose members are the named packages or provides that are listed. If a listed element is a provides, automatically includes the origin package that provides it. If a listed element is a subpackage, automatically includes the origin package that contains it. If a listed element does not exist, returns an error.