Documentation ¶
Index ¶
- Variables
- func AutoVersion(path string) (version string, err error)
- func ParseGlob(from string) (glob.Glob, error)
- func ValidatePackageSource(httpClient *http.Client, url string) error
- type Action
- type AnnotatedManifest
- type AutoVersionBlock
- type ChannelBlock
- type ChmodAction
- type Config
- type CopyAction
- type DeleteAction
- type Event
- type Layer
- type Loader
- type Manifest
- type ManifestErrors
- type MessageAction
- type Package
- func (p *Package) ApplyEnvironment(envRoot string, env envars.Envars)
- func (p *Package) DeprecationWarningf(format string, args ...interface{})
- func (p *Package) EnsureSupported() error
- func (p *Package) LogWarnings(l *ui.UI)
- func (p *Package) ResolveBinaries() ([]string, error)
- func (p *Package) String() string
- func (p *Package) Trigger(l ui.Logger, event Event) (messages []string, err error)
- func (p *Package) Unsupported() bool
- type PackageState
- type Packages
- type PlatformBlock
- type Reference
- func (r Reference) Compare(other Reference) int
- func (r Reference) GoString() string
- func (r Reference) IsChannel() bool
- func (r Reference) IsFullyQualified() bool
- func (r Reference) IsSet() bool
- func (r Reference) Less(other Reference) bool
- func (r Reference) Major() Reference
- func (r Reference) MajorMinor() Reference
- func (r Reference) Match(other Reference) bool
- func (r Reference) String() string
- func (r Reference) StringNoName() string
- type References
- type RenameAction
- type ResolvedFileRef
- type Resolver
- func (r *Resolver) Errors() ManifestErrors
- func (r *Resolver) LoadAll() error
- func (r *Resolver) Resolve(l *ui.UI, selector Selector) (pkg *Package, err error)
- func (r *Resolver) ResolveVirtual(name string) (pkgs []*Package, err error)
- func (r *Resolver) Search(l ui.Logger, pattern string) (Packages, error)
- func (r *Resolver) Sync(l *ui.UI, force bool) error
- type RunAction
- type Selector
- type Trigger
- type Version
- func (v Version) Clean() Version
- func (v Version) Compare(rhs Version) int
- func (v Version) Components() []string
- func (v Version) GoString() string
- func (v Version) IsSet() bool
- func (v Version) Less(other Version) bool
- func (v Version) Major() Version
- func (v Version) MajorMinor() Version
- func (v Version) MarshalJSON() ([]byte, error)
- func (v Version) Match(other Version) bool
- func (v Version) Metadata() string
- func (v Version) Prerelease() string
- func (v Version) PrereleaseComponents() []string
- func (v Version) String() string
- type VersionBlock
- type Versions
Constants ¶
This section is empty.
Variables ¶
var ErrNoBinaries = errors.New("no binaries or apps provided")
ErrNoBinaries is returned when a resolved package does not contain binaries or apps
var ErrNoSource = errors.New("no source provided")
ErrNoSource is returned when a resolved package does not contain source
var ErrUnknownPackage = errors.New("unknown package")
ErrUnknownPackage is returned when a package cannot be resolved.
Functions ¶
func AutoVersion ¶ added in v0.2.10
AutoVersion rewrites the given manifest with new version information if applicable.
Auto-versioning configuration is defined in a "version > auto-version" block. If a new version is found in the defined location then the version block's versions are updated.
Types ¶
type Action ¶
type Action interface { Apply(p *Package) error String() string // contains filtered or unexported methods }
Action interface implemented by all lifecycle trigger actions.
type AnnotatedManifest ¶
type AnnotatedManifest struct { FS fs.FS Path string // Fully qualified path to manifest, including the FS. Name string Errors []error *Manifest // May be nil if errors were encountered. }
AnnotatedManifest includes extra metadata not included in the manifest itself.
func (*AnnotatedManifest) String ¶
func (f *AnnotatedManifest) String() string
type AutoVersionBlock ¶ added in v0.2.12
type AutoVersionBlock struct { GitHubRelease string `hcl:"github-release" help:"GitHub <user>/<repo> to retrieve and update versions from the releases API."` VersionPattern string `` /* 130-byte string literal not displayed */ }
AutoVersionBlock represents auto-version configuration.
type ChannelBlock ¶
type ChannelBlock struct { Name string `hcl:"name,label" help:"Name of the channel (eg. stable, alpha, etc.)."` Update time.Duration `hcl:"update" help:"Update frequency for this channel."` Version string `` /* 144-byte string literal not displayed */ Layer }
ChannelBlock is a Layer block specifying an installable channel for a package.
type ChmodAction ¶
type ChmodAction struct { Pos hcl.Position `hcl:"-"` Mode int `hcl:"mode" help:"File mode to set."` File string `hcl:"file" help:"File to set mode on."` }
ChmodAction changes the file mode on a file.
func (*ChmodAction) Apply ¶ added in v0.2.6
func (c *ChmodAction) Apply(*Package) error
func (*ChmodAction) String ¶
func (c *ChmodAction) String() string
type Config ¶
type Config struct { // Path to environment root. Env string // State path where packages are installed. State string // Optional OS (will use runtime.GOOS if not provided). OS string // Optional Arch (will use runtime.GOARCH if not provided). Arch string }
Config required for loading manifests.
type CopyAction ¶
type CopyAction struct { Pos hcl.Position `hcl:"-"` From string `` /* 149-byte string literal not displayed */ To string `hcl:"to" help:"The relative destination to copy to, based on the context."` Mode os.FileMode `hcl:"mode,optional" help:"File mode of file."` }
CopyAction is an action for copying
func (*CopyAction) Apply ¶ added in v0.2.6
func (c *CopyAction) Apply(p *Package) error
func (*CopyAction) String ¶
func (c *CopyAction) String() string
type DeleteAction ¶ added in v0.2.27
type DeleteAction struct { Pos hcl.Position `hcl:"-"` Recursive bool `hcl:"recursive,optional" help:"Recursively delete."` Files []string `hcl:"files" help:"Files to delete."` }
DeleteAction deletes files.
func (*DeleteAction) Apply ¶ added in v0.2.27
func (d *DeleteAction) Apply(*Package) error
func (*DeleteAction) String ¶ added in v0.2.27
func (d *DeleteAction) String() string
type Event ¶
type Event string
Event in the lifecycle of a package.
const ( // Package specific events EventUnpack Event = "unpack" EventInstall Event = "install" EventUninstall Event = "uninstall" // Environment specific events EventEnvActivate Event = "activate" )
Lifecycle events.
func (*Event) UnmarshalText ¶ added in v0.2.27
type Layer ¶
type Layer struct { Arch string `hcl:"arch,optional" help:"CPU architecture to match (amd64, 386, arm, etc.)."` Binaries []string `hcl:"binaries,optional" help:"Relative glob from $root to individual terminal binaries."` Apps []string `hcl:"apps,optional" help:"Relative paths to Mac .app packages to install."` Rename map[string]string `hcl:"rename,optional" help:"Rename files after unpacking to ${root}."` Requires []string `hcl:"requires,optional" help:"Packages this one requires."` RuntimeDeps []string `` /* 128-byte string literal not displayed */ Provides []string `hcl:"provides,optional" help:"This package provides the given virtual packages."` Dest string `hcl:"dest,optional" help:"Override archive extraction destination for package."` Files map[string]string `hcl:"files,optional" help:"Files to load strings from to be used in the manifest."` Strip int `hcl:"strip,optional" help:"Number of path prefix elements to strip."` Root string `hcl:"root,optional" help:"Override root for package."` Test *string `hcl:"test,optional" help:"Command that will test the package is operational."` Env envars.Envars `hcl:"env,optional" help:"Environment variables to export."` Source string `` /* 193-byte string literal not displayed */ Mirrors []string `hcl:"mirrors,optional" help:"Mirrors to use if the primary source is unavailable."` SHA256 string `hcl:"sha256,optional" help:"SHA256 of source package for verification."` Darwin []*Layer `hcl:"darwin,block" help:"Darwin-specific configuration."` Linux []*Layer `hcl:"linux,block" help:"Linux-specific configuration."` Platform []*PlatformBlock `` /* 134-byte string literal not displayed */ Triggers []*Trigger `hcl:"on,block" help:"Triggers to run on lifecycle events."` }
A Layer contributes to the final merged manifest definition.
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader of manifests.
func (*Loader) All ¶
func (l *Loader) All() ([]*AnnotatedManifest, error)
All loads all package manifests and returns them.
Non-critical errors will be made available in each AnnotatedManifest and also via Errors().
func (*Loader) Errors ¶
func (l *Loader) Errors() ManifestErrors
Errors returns all errors encountered _so far_ by the Loader.
type Manifest ¶
type Manifest struct { Layer Default string `hcl:"default,optional" help:"Default version or channel if not specified."` Description string `hcl:"description" help:"Human readable description of the package."` Versions []VersionBlock `hcl:"version,block" help:"Definition of and configuration for a specific version."` Channels []ChannelBlock `hcl:"channel,block" help:"Definition of and configuration for an auto-update channel."` }
Manifest for a package.
func InferFromArtefact ¶ added in v0.2.22
func InferFromArtefact(p *ui.UI, httpClient *http.Client, ghClient *github.Client, url, version string) (*Manifest, error)
InferFromArtefact attempts to infer a Manifest from a package artefact.
"url" should be the full URL to a package artefact.
https://github.com/protocolbuffers/protobuf-go/releases/download/v1.27.1/protoc-gen-go.v1.27.1.darwin.amd64.tar.gz
"version" may be specified if it cannot be inferred from the URL.
func (*Manifest) ChannelByName ¶
func (m *Manifest) ChannelByName(name string) *ChannelBlock
ChannelByName returns the channel with the given name, or nil if not found
func (*Manifest) GetChannels ¶ added in v0.2.18
GetChannels returns all the channels defined in this manifest.
func (*Manifest) GetVersions ¶ added in v0.2.18
GetVersions returns all the versions defined in this manifest
func (*Manifest) HighestMatch ¶
func (m *Manifest) HighestMatch(to glob.Glob) (result *VersionBlock, highest *Version)
HighestMatch returns the VersionBlock with highest version number matching the given Glob
func (*Manifest) References ¶ added in v0.2.21
func (m *Manifest) References(name string) References
References defined in this manifest
type ManifestErrors ¶
ManifestErrors are collection of errors for named manifests
func (ManifestErrors) LogErrors ¶
func (merrors ManifestErrors) LogErrors(l ui.Logger)
LogErrors to the given logger
type MessageAction ¶
type MessageAction struct { Pos hcl.Position `hcl:"-"` Text string `hcl:"text" help:"Message text to display to user."` }
MessageAction displays a message to the user.
func (*MessageAction) Apply ¶ added in v0.2.6
func (m *MessageAction) Apply(p *Package) error
func (*MessageAction) String ¶
func (m *MessageAction) String() string
type Package ¶
type Package struct { Description string Reference Reference Arch string Binaries []string Apps []string Requires []string RuntimeDeps []Reference Provides []string Env envars.Ops Source string Mirrors []string Root string SHA256 string Dest string Test string Strip int Triggers map[Event][]Action `json:"-"` // Triggers keyed by event. UpdateInterval time.Duration // How often should we check for updates? 0, if never Files []*ResolvedFileRef `json:"-"` FS fs.FS `json:"-"` // FS the Package was loaded from. Warnings []string `json:"-"` UnsupportedPlatforms []platform.Platform // Unsupported core platforms // Filled in by Env. Linked bool `json:"-"` // Linked into environment. State PackageState LastUsed time.Time ETag string UpdatedAt time.Time }
Package resolved from a manifest.
func (*Package) ApplyEnvironment ¶
ApplyEnvironment applies the env ops defined in the Package to the given environment.
func (*Package) DeprecationWarningf ¶
DeprecationWarningf adds a new deprecation warning to the Package's warnings.
func (*Package) EnsureSupported ¶ added in v0.2.18
EnsureSupported returns an error if the package is not supported on this platform
func (*Package) LogWarnings ¶
LogWarnings logs possible warnings found in the package manifest
func (*Package) ResolveBinaries ¶
ResolveBinaries resolves binary globs from the filesystem.
func (*Package) Trigger ¶
Trigger triggers an event in this package. Noop if the event is not defined for the package
func (*Package) Unsupported ¶ added in v0.2.18
Unsupported package in this environment.
type PackageState ¶
type PackageState int
PackageState is the state a package is in.
const ( PackageStateRemote PackageState = iota // remote PackageStateDownloaded // downloaded PackageStateInstalled // installed )
Different states a package can be in.
func (PackageState) MarshalJSON ¶
func (s PackageState) MarshalJSON() ([]byte, error)
func (PackageState) String ¶
func (i PackageState) String() string
type Packages ¶
type Packages []*Package
Packages sortable by name + version.
Prerelease versions will sort as the oldest versions.
type PlatformBlock ¶ added in v0.2.13
type PlatformBlock struct { Attrs []string `hcl:"attr,label" help:"Platform attributes to match."` Layer }
PlatformBlock matches a set of attributes describing a platform (eg. CPU, OS, etc.)
The PlatformBlock replaces "linux" and "darwin".
type Reference ¶
A Reference to a package, potentially only providing partial versions, etc.
func ParseReference ¶
ParseReference parses a name+version for a package.
func (Reference) IsFullyQualified ¶
IsFullyQualified returns true if the Reference is fully qualified, ie. has a version or channel.
func (Reference) MajorMinor ¶
MajorMinor package-major.minor of the package reference.
func (Reference) Match ¶
Match returns true if the name and version components we have match those of other.
func (Reference) StringNoName ¶
StringNoName returns the formatted version+channel portion of the reference.
type References ¶
type References []Reference
References is a sortable list of Reference's.
func (References) Len ¶
func (r References) Len() int
func (References) Less ¶
func (r References) Less(i, j int) bool
func (References) Swap ¶
func (r References) Swap(i, j int)
type RenameAction ¶
type RenameAction struct { Pos hcl.Position `hcl:"-"` From string `hcl:"from" help:"Source path to rename."` To string `hcl:"to" help:"Destination path to rename to."` }
RenameAction renames a file.
func (*RenameAction) Apply ¶ added in v0.2.6
func (r *RenameAction) Apply(*Package) error
func (*RenameAction) String ¶
func (r *RenameAction) String() string
type ResolvedFileRef ¶
ResolvedFileRef contains information of a file that should be copied to the target package after unpacking
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver of packages.
func (*Resolver) Errors ¶
func (r *Resolver) Errors() ManifestErrors
Errors returns all errors encountered _so far_ by the Loader.
func (*Resolver) Resolve ¶
Resolve a package reference.
Returns the highest version matching the given reference
func (*Resolver) ResolveVirtual ¶
ResolveVirtual references to concrete packages.
type RunAction ¶
type RunAction struct { Pos hcl.Position `hcl:"-"` Command string `hcl:"cmd" help:"The command to execute, split by shellquote."` Dir string `hcl:"dir,optional" help:"The directory where the command is run. Defaults to the ${root} directory."` Args []string `hcl:"args,optional" help:"The arguments to the binary."` Env []string `hcl:"env,optional" help:"The environment variables for the execution."` Stdin string `hcl:"stdin,optional" help:"Optional string to be used as the stdin for the command."` }
RunAction executes a command when a lifecycle event occurs
type Selector ¶
type Selector interface { // Name of the package without version or channel qualifiers Name() string // String representation of this selector String() string // Matches checks if the selector matches this Reference Matches(ref Reference) bool // IsFullyQualified returns true if the selector specifies a version or a channel IsFullyQualified() bool }
Selector is a selector that matches package References and can be used to select a specific version of a package
func ExactSelector ¶
ExactSelector returns a selector that matches packages matching exactly the given reference
func GlobSelector ¶
GlobSelector parses the given search string into a Glob based selector
func NameSelector ¶
NameSelector returns a selector that matches all package versions of the given name
func PrefixSelector ¶
PrefixSelector returns a selector that matches packages with this reference as a prefix
type Trigger ¶
type Trigger struct { Event Event `hcl:"event,label" help:"Event to Trigger (unpack, install, activate)."` Run []*RunAction `hcl:"run,block" help:"A command to run when the event is triggered."` Copy []*CopyAction `hcl:"copy,block" help:"A file to copy when the event is triggered."` Chmod []*ChmodAction `hcl:"chmod,block" help:"Change a files mode."` Rename []*RenameAction `hcl:"rename,block" help:"Rename a file."` Delete []*DeleteAction `hcl:"delete,block" help:"Delete files."` Message []*MessageAction `hcl:"message,block" help:"Display a message to the user."` }
A Trigger applied when a lifecycle event occurs.
type Version ¶
type Version struct {
// contains filtered or unexported fields
}
Version of a package.
This is very loosely parsed to support the myriad different ways of specifying versions, though it does attempt to support semver prerelease and metadata.
func ParseVersion ¶
ParseVersion "parses" a package version.
func (Version) Compare ¶
Compare two versions.
This attempts to follow semantic versioning, ie. prereleases are not considered and metadata is ignored.
func (Version) Components ¶
Components returns the numeric version number components of the
func (Version) MajorMinor ¶
MajorMinor version number components only (includes prerelease + metadata).
func (Version) MarshalJSON ¶
func (Version) Match ¶
Match returns true if this version is equal to or a more general version of "other".
That is, if "other" is "1.2.3" and our version is "1.2" this will return true.
func (Version) Prerelease ¶
Prerelease data in the version, if any.
func (Version) PrereleaseComponents ¶
PrereleaseComponents returns the . separated parts of the prerelease section.
type VersionBlock ¶
type VersionBlock struct { Version []string `hcl:"version,label" help:"Version(s) of package."` AutoVersion *AutoVersionBlock `hcl:"auto-version,block" help:"Automatically update versions."` Layer }
VersionBlock is a Layer block specifying an installable version of a package.