manifest

package
v0.39.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoBinaries = errors.New("no binaries or apps provided")

ErrNoBinaries is returned when a resolved package does not contain binaries or apps

View Source
var ErrNoSource = errors.New("no source provided")

ErrNoSource is returned when a resolved package does not contain source

View Source
var ErrUnknownPackage = errors.New("unknown package")

ErrUnknownPackage is returned when a package cannot be resolved.

Functions

func ParseGlob

func ParseGlob(from string) (glob.Glob, error)

ParseGlob parses a version glob into a Glob selector

func ValidatePackageSource added in v0.2.22

func ValidatePackageSource(packageSource cache.PackageSourceSelector, httpClient *http.Client, url string) error

ValidatePackageSource checks that a package source is accessible.

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 LoadManifestFile added in v0.29.0

func LoadManifestFile(dir fs.FS, path string) (*AnnotatedManifest, error)

LoadManifestFile Utility function to just load a manifest file.

func (*AnnotatedManifest) String

func (f *AnnotatedManifest) String() string

type AutoVersionBlock added in v0.2.12

type AutoVersionBlock struct {
	GitHubRelease string                `hcl:"github-release,optional" help:"GitHub <user>/<repo> to retrieve and update versions from the releases API."`
	HTML          *HTMLAutoVersionBlock `hcl:"html,block" help:"Extract version information from a HTML URL using XPath."`

	VersionPattern        string `` /* 130-byte string literal not displayed */
	IgnoreInvalidVersions bool   `` /* 165-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
	platform.Platform
}

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"
	EventExec      Event = "exec" // Triggered when a binary in a package is executed.
	// Environment specific events
	EventEnvActivate Event = "activate"
)

Lifecycle events.

func (*Event) UnmarshalText added in v0.2.27

func (e *Event) UnmarshalText(text []byte) error

type GlobSelector

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

GlobSelector selects matching packages using a glob.

Can be used directly with Kong.

func MustParseGlobSelector added in v0.7.0

func MustParseGlobSelector(from string) GlobSelector

MustParseGlobSelector or die.

func ParseGlobSelector added in v0.7.0

func ParseGlobSelector(from string) (GlobSelector, error)

ParseGlobSelector parses the given search string into a Glob based selector

func (GlobSelector) IsFullyQualified added in v0.7.0

func (m GlobSelector) IsFullyQualified() bool

func (GlobSelector) Matches added in v0.7.0

func (m GlobSelector) Matches(ref Reference) bool

func (GlobSelector) Name added in v0.7.0

func (m GlobSelector) Name() string

func (GlobSelector) String added in v0.7.0

func (m GlobSelector) String() string

func (*GlobSelector) UnmarshalText added in v0.7.0

func (m *GlobSelector) UnmarshalText(input []byte) error

type HTMLAutoVersionBlock added in v0.7.0

type HTMLAutoVersionBlock struct {
	URL   string `hcl:"url" help:"URL to retrieve HTML from."`
	XPath string `` /* 153-byte string literal not displayed */
	CSS   string `` /* 161-byte string literal not displayed */
}

HTMLAutoVersionBlock defines how version numbers can be extracted from HTML.

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."`
	Vars         map[string]string `hcl:"vars,optional" help:"Set local variables used during manifest evaluation."`
	Source       string            `` /* 201-byte string literal not displayed */
	DontExtract  bool              `hcl:"dont-extract,optional" help:"Don't extract the package source, just copy it into the installation directory."`
	Mirrors      []string          `hcl:"mirrors,optional" help:"Mirrors to use if the primary source is unavailable."`
	SHA256       string            `` /* 144-byte string literal not displayed */
	SHA256Source string            `hcl:"sha256-source,optional" help:"URL for SHA256 checksum file for source package."`
	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."`
	Mutable      bool              `hcl:"mutable,optional" help:"Package will not be made read-only."`
}

A Layer contributes to the final merged manifest definition.

type Loader

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

Loader of manifests.

func NewLoader

func NewLoader(sources *sources.Sources) *Loader

NewLoader constructs a new Loader.

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.

func (*Loader) Load added in v0.2.21

func (l *Loader) Load(u *ui.UI, name string) (*AnnotatedManifest, error)

Load a manifest for the given package. Syncs the sources if the manifest is not initially found. Will return a wrapped ErrUnknownPackage if the package could not be found.

If any errors occur during the load, the first error will be returned.

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."`
	Homepage    string            `hcl:"homepage,optional" help:"Home page."`
	Repository  string            `hcl:"repository,optional" help:"Source Repository."`
	SHA256Sums  map[string]string `hcl:"sha256sums,optional" help:"SHA256 checksums of source packages for verification."`
	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, packageSource cache.PackageSourceSelector, 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

func (m *Manifest) GetChannels() []string

GetChannels returns all the channels defined in this manifest.

func (*Manifest) GetVersions added in v0.2.18

func (m *Manifest) GetVersions() []Version

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

type ManifestErrors map[string][]error

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 MkdirAction added in v0.34.0

type MkdirAction struct {
	Pos hcl.Position `hcl:"-"`

	Dir  string      `hcl:"dir" help:"The absolute directory to create."`
	Mode os.FileMode `hcl:"mode,optional" help:"File mode of directory."`
}

MkdirAction is an action for creating a directory.

func (*MkdirAction) Apply added in v0.34.0

func (m *MkdirAction) Apply(*Package) error

func (*MkdirAction) String added in v0.34.0

func (m *MkdirAction) String() string

type Package

type Package struct {
	Description          string
	Homepage             string
	Repository           string
	Reference            Reference
	Arch                 string
	Binaries             []string
	Apps                 []string
	Requires             []string
	RuntimeDeps          []Reference
	Provides             []string
	Env                  envars.Ops
	Source               string
	SHA256Source         string
	DontExtract          bool // Don't extract the package, just download it.
	Mirrors              []string
	Root                 string
	SHA256               string
	Mutable              bool
	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
	ETag      string
	UpdatedAt time.Time
}

Package resolved from a manifest.

func Resolve added in v0.30.0

func Resolve(manifest *AnnotatedManifest, config Config, ref Reference) (*Package, error)

Resolve a concrete Package reference for the given Config.

func (*Package) ApplyEnvironment

func (p *Package) ApplyEnvironment(envRoot string, env envars.Envars)

ApplyEnvironment applies the env ops defined in the Package to the given environment.

func (*Package) DeprecationWarningf

func (p *Package) DeprecationWarningf(format string, args ...interface{})

DeprecationWarningf adds a new deprecation warning to the Package's warnings.

func (*Package) EnsureSupported added in v0.2.18

func (p *Package) EnsureSupported() error

EnsureSupported returns an error if the package is not supported on this platform

func (*Package) LogWarnings

func (p *Package) LogWarnings(l *ui.UI)

LogWarnings logs possible warnings found in the package manifest

func (*Package) ResolveBinaries

func (p *Package) ResolveBinaries() ([]string, error)

ResolveBinaries resolves binary globs from the filesystem.

func (*Package) String

func (p *Package) String() string

func (*Package) Trigger

func (p *Package) Trigger(l ui.Logger, event Event) (messages []string, err error)

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

func (p *Package) Unsupported() bool

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.

func (Packages) Len

func (p Packages) Len() int

func (Packages) Less

func (p Packages) Less(i, j int) bool

func (Packages) Swap

func (p Packages) Swap(i, j int)

type PlatformBlock added in v0.2.13

type PlatformBlock struct {
	Attrs []string `hcl:"attr,label" help:"Regex to match against platform attributes <arch>, <os>, and <arch>-<os>."`
	Layer
}

PlatformBlock matches a set of attributes describing a platform (eg. CPU, OS, etc.)

The PlatformBlock replaces "linux" and "darwin".

type Reference

type Reference struct {
	Name    string
	Version Version
	Channel string
}

A Reference to a package, potentially only providing partial versions, etc.

func ParseReference

func ParseReference(pkg string) Reference

ParseReference parses a name+version for a package.

func (Reference) Compare

func (r Reference) Compare(other Reference) int

Compare reference to another, returning -1, 0, or +1.

func (Reference) GoString

func (r Reference) GoString() string

func (Reference) IsChannel

func (r Reference) IsChannel() bool

IsChannel returns true if the reference refers to a channel package

func (Reference) IsFullyQualified

func (r Reference) IsFullyQualified() bool

IsFullyQualified returns true if the Reference is fully qualified, ie. has a version or channel.

func (Reference) IsSet

func (r Reference) IsSet() bool

IsSet returns true if the Reference isn't empty.

func (Reference) Less

func (r Reference) Less(other Reference) bool

Less returns true if other is less than us.

func (Reference) Major

func (r Reference) Major() Reference

Major package-major of the package reference.

func (Reference) MajorMinor

func (r Reference) MajorMinor() Reference

MajorMinor package-major.minor of the package reference.

func (Reference) Match

func (r Reference) Match(other Reference) bool

Match returns true if the name and version components we have match those of other.

func (Reference) String

func (r Reference) String() string

func (Reference) StringNoName

func (r Reference) StringNoName() string

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

type ResolvedFileRef struct {
	FS       fs.FS
	FromPath string
	ToPath   string
}

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 New

func New(sources *sources.Sources, config Config) (*Resolver, error)

New constructs a new package loader.

func (*Resolver) Errors

func (r *Resolver) Errors() ManifestErrors

Errors returns all errors encountered _so far_ by the Loader.

func (*Resolver) LoadAll

func (r *Resolver) LoadAll() error

LoadAll manifests.

func (*Resolver) Resolve

func (r *Resolver) Resolve(l *ui.UI, selector Selector) (*Package, error)

Resolve a package reference.

Returns the highest version matching the given reference

func (*Resolver) ResolveVirtual

func (r *Resolver) ResolveVirtual(name string) (pkgs []*Package, err error)

ResolveVirtual references to concrete packages.

func (*Resolver) Search

func (r *Resolver) Search(l ui.Logger, pattern string) (Packages, error)

Search for packages using the given regular expression.

func (*Resolver) Sync

func (r *Resolver) Sync(l *ui.UI, force bool) error

Sync the sources of this resolver.

Will be synced at most every SyncFrequency unless "force" is true.

A Sources set can only be synchronised once. Following calls will not have any effect.

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

func (*RunAction) Apply added in v0.2.6

func (r *RunAction) Apply(p *Package) error

func (*RunAction) String

func (r *RunAction) String() string

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

func ExactSelector(ref Reference) Selector

ExactSelector returns a selector that matches packages matching exactly the given reference

func NameSelector

func NameSelector(name string) Selector

NameSelector returns a selector that matches all package versions of the given name

func PrefixSelector

func PrefixSelector(ref Reference) Selector

PrefixSelector returns a selector that matches packages with this reference as a prefix

type SymlinkAction added in v0.34.0

type SymlinkAction struct {
	Pos hcl.Position `hcl:"-"`

	From string `hcl:"from" help:"The absolute source file to symlink from."`
	To   string `hcl:"to" help:"The absolute destination to symlink to."`
}

SymlinkAction is an action for creating symlinks.

func (*SymlinkAction) Apply added in v0.34.0

func (s *SymlinkAction) Apply(*Package) error

func (*SymlinkAction) String added in v0.34.0

func (s *SymlinkAction) String() string

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."`
	Mkdir   []*MkdirAction   `hcl:"mkdir,block" help:"Create a directory and any missing parents."`
	Symlink []*SymlinkAction `hcl:"symlink,block" help:"Create a symbolic link."`
}

A Trigger applied when a lifecycle event occurs.

func (*Trigger) Ordered

func (a *Trigger) Ordered() []Action

Ordered list of actions.

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

func ParseVersion(version string) Version

ParseVersion "parses" a package version.

func (Version) Clean added in v0.2.2

func (v Version) Clean() Version

Clean pre-release and metadata.

func (Version) Compare

func (v Version) Compare(rhs Version) int

Compare two versions.

This attempts to follow semantic versioning, ie. prereleases are not considered and metadata is ignored.

func (Version) Components

func (v Version) Components() []string

Components returns the numeric version number components of the

func (Version) GoString

func (v Version) GoString() string

func (Version) IsSet

func (v Version) IsSet() bool

IsSet returns true if the Version is set.

func (Version) Less

func (v Version) Less(other Version) bool

Less return true if this version is smaller than the given version

func (Version) Major

func (v Version) Major() Version

Major version number components only (includes prerelease + metadata).

func (Version) MajorMinor

func (v Version) MajorMinor() Version

MajorMinor version number components only (includes prerelease + metadata).

func (Version) MarshalJSON

func (v Version) MarshalJSON() ([]byte, error)

func (Version) Match

func (v Version) Match(other Version) bool

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) Metadata

func (v Version) Metadata() string

Metadata in the version, if any.

See https://semver.org/#spec-item-10

func (Version) Prerelease

func (v Version) Prerelease() string

Prerelease data in the version, if any.

See https://semver.org/#spec-item-9

func (Version) PrereleaseComponents

func (v Version) PrereleaseComponents() []string

PrereleaseComponents returns the . separated parts of the prerelease section.

func (Version) String

func (v Version) String() string

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.

type Versions

type Versions []Version

Versions sortable.

func (Versions) Len

func (v Versions) Len() int

func (Versions) Less

func (v Versions) Less(i, j int) bool

func (Versions) Swap

func (v Versions) Swap(i, j int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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