Documentation ¶
Index ¶
- Constants
- func ExternalReach(basedir, projname string) (rm map[string][]string, err error)
- func IterativeScan(path string) ([]string, error)
- type Constraint
- type ConstraintType
- type Dependency
- type Lock
- type Manifest
- type PairedVersion
- type ProjectAnalyzer
- type ProjectAtom
- type ProjectDep
- type ProjectExistence
- type ProjectInfo
- type ProjectManager
- type ProjectName
- type Result
- type Revision
- type SolveError
- type Solver
- type SourceManager
- type UnpairedVersion
- type Version
Constants ¶
const ( // ExistsInLock indicates that a project exists (i.e., is mentioned in) a // lock file. // TODO not sure if it makes sense to have this IF it's just the source // manager's responsibility for putting this together - the implication is // that this is the root lock file, right? ExistsInLock = 1 << iota // ExistsInManifest indicates that a project exists (i.e., is mentioned in) // a manifest. ExistsInManifest // ExistsInVendorRoot indicates that a project exists in a vendor directory // at the predictable location based on import path. It does NOT imply, much // less guarantee, any of the following: // - That the code at the expected location under vendor is at the version // given in a lock file // - That the code at the expected location under vendor is from the // expected upstream project at all // - That, if this flag is not present, the project does not exist at some // unexpected/nested location under vendor // - That the full repository history is available. In fact, the // assumption should be that if only this flag is on, the full repository // history is likely not available (locally) // // In short, the information encoded in this flag should not be construed as // exhaustive. ExistsInVendorRoot // ExistsInCache indicates that a project exists on-disk in the local cache. // It does not guarantee that an upstream exists, thus it cannot imply // that the cache is at all correct - up-to-date, or even of the expected // upstream project repository. // // Additionally, this refers only to the existence of the local repository // itself; it says nothing about the existence or completeness of the // separate metadata cache. ExistsInCache // ExistsUpstream indicates that a project repository was locatable at the // path provided by a project's URI (a base import path). ExistsUpstream )
Variables ¶
This section is empty.
Functions ¶
func ExternalReach ¶ added in v0.1.0
ExternalReach takes a base directory (a project root), and computes the list of external dependencies (not under the tree at that project root) that are imported by packages in that project tree.
projname indicates the import path-level name that constitutes the root of the project tree (used to decide whether an encountered import path is "internal" or "external").
func IterativeScan ¶ added in v0.1.0
IterativeScan attempts to obtain a list of imported dependencies from a package. This scanning is different from ImportDir as part of the go/build package. It looks over different permutations of the supported OS/Arch to try and find all imports. This is different from setting UseAllFiles to true on the build Context. It scopes down to just the supported OS/Arch.
Note, there are cases where multiple packages are in the same directory. This usually happens with an example that has a main package and a +build tag of ignore. This is a bit of a hack. It causes UseAllFiles to have errors.
Types ¶
type Constraint ¶
type Constraint interface { fmt.Stringer // Matches indicates if the provided Version is allowed by the Constraint. Matches(Version) bool // MatchesAny indicates if the intersection of the Constraint with the // provided Constraint would yield a Constraint that could allow *any* // Version. MatchesAny(Constraint) bool // Intersect computes the intersection of the Constraint with the provided // Constraint. Intersect(Constraint) Constraint // contains filtered or unexported methods }
A Constraint provides structured limitations on the versions that are admissible for a given project.
As with Version, it has a private method because the vsolver's internal implementation of the problem is complete, and the system relies on type magic to operate.
func NewConstraint ¶
func NewConstraint(t ConstraintType, body string) (Constraint, error)
NewConstraint constructs an appropriate Constraint object from the input parameters.
type ConstraintType ¶
type ConstraintType uint8
const ( RevisionConstraint ConstraintType = iota BranchConstraint VersionConstraint SemverConstraint )
type Dependency ¶
type Dependency struct { Depender ProjectAtom Dep ProjectDep }
type Lock ¶
type Lock interface { // Indicates the version of the solver used to generate this lock file SolverVersion() string // The hash of inputs to the solver that resulted in this lock file InputHash() string // Returns the identifier for a project in the lock file, or nil if the // named project is not present in the lock file GetProjectAtom(ProjectName) *ProjectAtom }
type Manifest ¶ added in v0.1.0
type Manifest interface { Name() ProjectName GetDependencies() []ProjectDep GetDevDependencies() []ProjectDep }
type PairedVersion ¶ added in v0.1.0
type PairedVersion interface { Version // Underlying returns the immutable Revision that identifies this Version. Underlying() Revision // contains filtered or unexported methods }
PairedVersion represents a normal Version, but paired with its corresponding, underlying Revision.
type ProjectAnalyzer ¶ added in v0.1.0
type ProjectAnalyzer interface {
GetInfo(build.Context, ProjectName) (ProjectInfo, error)
}
type ProjectAtom ¶ added in v0.1.0
type ProjectAtom struct { Name ProjectName Version Version }
type ProjectDep ¶
type ProjectDep struct { Name ProjectName Constraint Constraint }
type ProjectExistence ¶
type ProjectExistence uint8
ProjectExistence values represent the extent to which a project "exists."
type ProjectInfo ¶
ProjectInfo holds the spec and lock information for a given ProjectAtom
type ProjectManager ¶ added in v0.1.0
type ProjectManager interface { GetInfoAt(Version) (ProjectInfo, error) ListVersions() ([]Version, error) CheckExistence(ProjectExistence) bool ExportVersionTo(Version, string) error }
type ProjectName ¶ added in v0.1.0
type ProjectName string
type Result ¶
type Result struct { // A list of the projects selected by the solver. nil if solving failed. Projects []ProjectAtom // The number of solutions that were attempted Attempts int // The error that ultimately prevented reaching a successful conclusion. nil // if solving was successful. // TODO proper error types SolveFailure error }
func (Result) CreateVendorTree ¶ added in v0.1.0
func (r Result) CreateVendorTree(basedir string, sm SourceManager) error
type Revision ¶ added in v0.1.0
type Revision string
A Revision represents an immutable versioning identifier.
func (Revision) Intersect ¶ added in v0.1.0
func (r Revision) Intersect(c Constraint) Constraint
func (Revision) Matches ¶ added in v0.1.0
Admits is the Revision acting as a constraint; it checks to see if the provided version is the same Revision as itself.
func (Revision) MatchesAny ¶ added in v0.1.0
func (r Revision) MatchesAny(c Constraint) bool
AdmitsAny is the Revision acting as a constraint; it checks to see if the provided version is the same Revision as itself.
type SolveError ¶
type Solver ¶
type Solver interface {
Solve(root ProjectInfo, toUpgrade []ProjectName) Result
}
type SourceManager ¶
type SourceManager interface { GetProjectInfo(ProjectAtom) (ProjectInfo, error) ListVersions(ProjectName) ([]Version, error) RepoExists(ProjectName) (bool, error) VendorCodeExists(ProjectName) (bool, error) ExportAtomTo(ProjectAtom, string) error Release() }
func NewSourceManager ¶ added in v0.1.0
func NewSourceManager(cachedir, basedir string, upgrade, force bool, an ProjectAnalyzer) (SourceManager, error)
type UnpairedVersion ¶ added in v0.1.0
type UnpairedVersion interface { Version // Is takes the underlying Revision that this (Unpaired)Version corresponds // to and unites them into a PairedVersion. Is(Revision) PairedVersion // contains filtered or unexported methods }
UnpairedVersion represents a normal Version, with a method for creating a VersionPair by indicating the version's corresponding, underlying Revision.
func NewFloatingVersion ¶ added in v0.1.0
func NewFloatingVersion(body string) UnpairedVersion
NewFloatingVersion creates a new Version to represent a floating version (in general, a branch).
func NewVersion ¶ added in v0.1.0
func NewVersion(body string) UnpairedVersion
NewVersion creates a Semver-typed Version if the provided version string is valid semver, and a plain/non-semver version if not.
type Version ¶
type Version interface { // Version composes Stringer to ensure that all versions can be serialized // to a string fmt.Stringer // contains filtered or unexported methods }
Version represents one of the different types of versions used by vsolver.
Version is an interface, but it contains private methods, which restricts it to vsolver's own internal implementations. We do this for the confluence of two reasons:
- the implementation of Versions is complete (there is no case in which we'd need other types)
- the implementation relies on type magic under the hood, which would be unsafe to do if other dynamic types could be hiding behind the interface.