modrequirements

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MajorVersionDefaultStatus

type MajorVersionDefaultStatus byte
const (
	ExplicitDefault MajorVersionDefaultStatus = iota
	NonExplicitDefault
	NoDefault
	AmbiguousDefault
)

type ModuleGraph

type ModuleGraph struct {
	// contains filtered or unexported fields
}

A ModuleGraph represents the complete graph of module dependencies of a main module.

If the main module supports module graph pruning, the graph does not include transitive dependencies of non-root (implicit) dependencies.

func (*ModuleGraph) BuildList

func (mg *ModuleGraph) BuildList() []module.Version

BuildList returns the selected versions of all modules present in the graph, beginning with the main modules.

The order of the remaining elements in the list is deterministic but arbitrary.

The caller must not modify the returned list, but may safely append to it and may rely on it not to be modified.

func (*ModuleGraph) RequiredBy

func (mg *ModuleGraph) RequiredBy(m module.Version) (reqs []module.Version, ok bool)

RequiredBy returns the dependencies required by module m in the graph, or ok=false if module m's dependencies are pruned out.

The caller must not modify the returned slice, but may safely append to it and may rely on it not to be modified.

func (*ModuleGraph) Selected

func (mg *ModuleGraph) Selected(path string) (version string)

Selected returns the selected version of the module with the given path.

If no version is selected, Selected returns version "none".

func (*ModuleGraph) WalkBreadthFirst

func (mg *ModuleGraph) WalkBreadthFirst(f func(m module.Version))

WalkBreadthFirst invokes f once, in breadth-first order, for each module version other than "none" that appears in the graph, regardless of whether that version is selected.

type Registry

type Registry interface {
	Requirements(ctx context.Context, m module.Version) ([]module.Version, error)
}

Registry holds the contents of a registry. It's expected that this will cache any results that it returns.

type Requirements

type Requirements struct {
	// contains filtered or unexported fields
}

Requirements holds a set of module requirements. It does not initially load the full module graph, as that can be expensive. Instead the [Registry.Graph] method can be used to lazily construct that.

func NewRequirements

func NewRequirements(mainModulePath string, reg Registry, rootModules []module.Version, defaultMajorVersions map[string]string) *Requirements

NewRequirements returns a new requirement set with the given root modules. The dependencies of the roots will be loaded lazily from the given Registry value at the first call to the Graph method.

The rootModules slice must be sorted according to module.Sort.

The defaultMajorVersions slice holds the default major version for (major-version-less) mdule paths, if any have been specified. For example {"foo.com/bar": "v0"} specifies that the default major version for the module `foo.com/bar` is `v0`.

The caller must not modify rootModules or defaultMajorVersions after passing them to NewRequirements.

func (*Requirements) DefaultMajorVersion

func (rs *Requirements) DefaultMajorVersion(mpath string) (string, MajorVersionDefaultStatus)

DefaultMajorVersion returns the default major version for the given module path (which should not itself contain a major version).

It also returns information about the default.

func (*Requirements) DefaultMajorVersions

func (rs *Requirements) DefaultMajorVersions() map[string]string

DefaultMajorVersions returns the defaults that the requirements was created with. The returned map should not be modified.

func (*Requirements) Graph

func (rs *Requirements) Graph(ctx context.Context) (*ModuleGraph, error)

Graph returns the graph of module requirements loaded from the current root modules (as reported by RootModules).

Graph always makes a best effort to load the requirement graph despite any errors, and always returns a non-nil *ModuleGraph.

If the requirements of any relevant module fail to load, Graph also returns a non-nil error of type *mvs.BuildListError.

func (*Requirements) GraphIsLoaded

func (rs *Requirements) GraphIsLoaded() bool

GraphIsLoaded reports whether Graph has been called previously.

func (*Requirements) RootModules

func (rs *Requirements) RootModules() []module.Version

rootModules returns the set of root modules of the graph, sorted and capped to length. It may contain duplicates, and may contain multiple versions for a given module path.

func (*Requirements) RootSelected

func (rs *Requirements) RootSelected(mpath string) (version string, ok bool)

RootSelected returns the version of the root dependency with the given module path, or the zero module.Version and ok=false if the module is not a root dependency.

func (*Requirements) WithDefaultMajorVersions

func (rs *Requirements) WithDefaultMajorVersions(defaults map[string]string) *Requirements

WithDefaultMajorVersions returns rs but with the given default major versions. The caller should not modify the map after calling this method.

Jump to

Keyboard shortcuts

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