Documentation ¶
Overview ¶
Package versionology contains interfaces and structs so that this API does not rely directly on cargo structs. In particular, the versionology.VersionFetcher provides a way for buildpack authors to use the struct of their choice when writing the retrieval code.
Index ¶
- func ConstraintsToString(semverVersions []Constraint) []string
- func LogAllVersions(id, description string, versions []VersionFetcher)
- func VersionFetcherToString(semverVersions []VersionFetcher) []string
- func Versions(dependencies []Dependency) []string
- type Constraint
- type Dependency
- type SimpleVersionFetcher
- type VersionFetcher
- type VersionFetcherArray
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConstraintsToString ¶
func ConstraintsToString(semverVersions []Constraint) []string
ConstraintsToString translates from an array of Constraints to an array of strings Primarily intended as a test helper.
func LogAllVersions ¶ added in v0.6.0
func LogAllVersions(id, description string, versions []VersionFetcher)
LogAllVersions will print out a JSON array of the versions arranged as a block table. See Example tests for demonstration.
Example ¶
package main import ( "github.com/joshuatcasey/libdependency/versionology" ) func main() { array, err := versionology.NewSimpleVersionFetcherArray( "888.777.666", "1.0.0", "1.0.1", "1.0.2", "1.0.3", "1.0.4", "1.0.5", "1.0.6", "1.0.7", "1.0.8", "1.0.9", "1.10.0", "2.0.0", "2.0.1", "2.0.2", "2.0.3", "2.0.4", "2.0.5", "2.0.6", "2.0.7", "2.0.8", "2.0.9", "2.10.0") if err != nil { panic(err) } versionology.LogAllVersions("dep-id", "description", array) }
Output: Found 23 versions of dep-id description [ "888.777.666", "2.10.0", "2.0.9", "2.0.8", "2.0.7", "2.0.6", "2.0.5", "2.0.4", "2.0.3", "2.0.2", "2.0.1", "2.0.0", "1.10.0", "1.0.9", "1.0.8", "1.0.7", "1.0.6", "1.0.5", "1.0.4", "1.0.3", "1.0.2", "1.0.1", "1.0.0" ]
Example (OneVersion) ¶
package main import ( "github.com/joshuatcasey/libdependency/versionology" ) func main() { array, err := versionology.NewSimpleVersionFetcherArray("888.777.666") if err != nil { panic(err) } versionology.LogAllVersions("dep-id", "description", array) }
Output: Found 1 version of dep-id description [ "888.777.666" ]
func VersionFetcherToString ¶ added in v0.20.0
func VersionFetcherToString(semverVersions []VersionFetcher) []string
VersionFetcherToString translates from an array of VersionFetcher to an array of strings. Primarily intended as a test helper.
func Versions ¶ added in v0.20.0
func Versions(dependencies []Dependency) []string
Versions will return an array of strings that represents each version of the input Primarily intended as a test helper.
Types ¶
type Constraint ¶ added in v0.3.0
Constraint largely mimics cargo.ConfigMetadataDependencyConstraint but has a semver.Constraints instead of a string
func NewConstraint ¶ added in v0.3.0
func NewConstraint(c cargo.ConfigMetadataDependencyConstraint) (Constraint, error)
NewConstraint will translate a cargo.ConfigMetadataDependencyConstraint into a Constraint
func (Constraint) Check ¶ added in v0.3.0
func (c Constraint) Check(versionFetcher VersionFetcher) bool
Check tests if a version satisfies the constraints.
type Dependency ¶ added in v0.3.0
type Dependency struct { cargo.ConfigMetadataDependency SemverVersion *semver.Version `json:"-"` Target string `json:"target,omitempty"` }
Dependency exists as a way to "extend" cargo.ConfigMetadataDependency and also "implements" VersionFetcher
func NewDependency ¶ added in v0.20.0
func NewDependency(configMetadataDependency cargo.ConfigMetadataDependency, target string) (Dependency, error)
func NewDependencyArray ¶ added in v0.20.0
func NewDependencyArray(configMetadataDependency cargo.ConfigMetadataDependency, targets ...string) ([]Dependency, error)
func (Dependency) Version ¶ added in v0.3.0
func (d Dependency) Version() *semver.Version
type SimpleVersionFetcher ¶ added in v0.20.0
type SimpleVersionFetcher struct {
// contains filtered or unexported fields
}
SimpleVersionFetcher only contains a Semver Version and implements VersionFetcher
func NewSimpleVersionFetcher ¶ added in v0.20.0
func NewSimpleVersionFetcher(version *semver.Version) SimpleVersionFetcher
func (SimpleVersionFetcher) Version ¶ added in v0.20.0
func (s SimpleVersionFetcher) Version() *semver.Version
type VersionFetcher ¶ added in v0.20.0
type VersionFetcher interface {
Version() *semver.Version
}
VersionFetcher exists to allow buildpack authors to use a type of their own choosing when passing structs in and out of libdependency APIs.
type VersionFetcherArray ¶ added in v0.20.0
type VersionFetcherArray []VersionFetcher
func FilterUpstreamVersionsByConstraints ¶ added in v0.15.0
func FilterUpstreamVersionsByConstraints( id string, upstreamVersions VersionFetcherArray, constraints []Constraint, existingVersion VersionFetcherArray) VersionFetcherArray
FilterUpstreamVersionsByConstraints will return only those versions with the following properties: - contained in upstreamVersions - satisfy at least one constraint - newer than all existing dependencies
func NewSimpleVersionFetcherArray ¶ added in v0.20.0
func NewSimpleVersionFetcherArray(versions ...string) (VersionFetcherArray, error)
NewSimpleVersionFetcherArray will return a VersionFetcherArray containing the semver representation of the input
func NewVersionFetcherArray ¶ added in v0.20.0
func NewVersionFetcherArray() VersionFetcherArray
func (VersionFetcherArray) GetNewestVersion ¶ added in v0.20.0
func (versions VersionFetcherArray) GetNewestVersion() string
func (VersionFetcherArray) GetVersionStrings ¶ added in v0.20.0
func (versions VersionFetcherArray) GetVersionStrings() []string