forklift

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package forklift provides the core functionality of the forklift tool

Index

Constants

View Source
const (
	// DeplsDirName is the directory in a pallet which contains deployment
	// configurations.
	DeplsDirName = "deployments"
	// DeplsFileExt is the file extension for deployment configuration files.
	DeplDefFileExt = ".deploy.yml"
)
View Source
const (
	LockTypeVersion       = "version"
	LockTypePseudoversion = "pseudoversion"
)
View Source
const PalletDefFile = "forklift-pallet.yml"

PalletDefFile is the name of the file defining each Forklift pallet.

View Source
const ReqsDirName = "requirements"

ReqsDirName is the directory in a Forklift pallet which contains requirement configurations.

View Source
const (
	// ReqsPalletsDirName is the subdirectory in the requirements directory of a Forklift pallet which
	// contains pallet requirement configurations.
	ReqsPalletsDirName = "pallets"
)
View Source
const (
	// ReqsReposDirName is the subdirectory in the requirements directory of a Forklift pallet which
	// contains repo requirement configurations.
	ReqsReposDirName = "repositories"
)
View Source
const Timestamp = "20060102150405"
View Source
const VersionLockDefFile = "forklift-version-lock.yml"

VersionLockDefFile is the name of the file defining each version lock of a repo.

Variables

This section is empty.

Functions

func CheckDeplDeps added in v0.2.0

func CheckDeplDeps(
	depls []*ResolvedDepl,
) (satisfiedDeps []SatisfiedDeplDeps, missingDeps []MissingDeplDeps, err error)

CheckDeplDeps produces reports of all satisfied and unsatisfied resource dependencies among all provided ResolvedDepl instances.

func CompareGitRepoReqs added in v0.6.0

func CompareGitRepoReqs(r, s GitRepoReq) int

CompareGitRepoReqs returns an integer comparing two RepoReq instances according to their paths and versions. The result will be 0 if the r and s have the same paths and versions; -1 if r has a path which alphabetically comes before the path of s or if the paths are the same but r has a lower version than s; or +1 if r has a path which alphabetically comes after the path of s or if the paths are the same but r has a higher version than s.

func ComparePallets added in v0.6.0

func ComparePallets(r, s Pallet) int

ComparePallets returns an integer comparing two Pallet instances according to their paths and versions. The result will be 0 if the r and s have the same paths and versions; -1 if r has a path which alphabetically comes before the path of s or if the paths are the same but r has a lower version than s; or +1 if r has a path which alphabetically comes after the path of s or if the paths are the same but r has a higher version than s.

func EnsureExists added in v0.1.8

func EnsureExists(dirPath string) error

func Exists added in v0.1.8

func Exists(dirPath string) bool

func GetCommitTimestamp added in v0.1.8

func GetCommitTimestamp(c CommitTimeGetter, hash string) (string, error)

func ResolveDeps added in v0.5.0

func ResolveDeps(
	satisfiedDeps []SatisfiedDeplDeps, skipNonblocking bool,
) structures.Digraph[string]

ResolveDeps returns a digraph where each node is the name of a deployment and each edge goes from a deployment which requires some resource to a deployment which provides that resource. Thus, the returned graph is a graph of direct dependencies among deployments, excluding deployments with no dependency relationships. If the skipNonblocking arg is set, then nonblocking resource requirements are ignored as if they didn't exist.

func ShortCommit

func ShortCommit(commit string) string

func ToTimestamp

func ToTimestamp(t time.Time) string

Types

type CommitTimeGetter added in v0.1.8

type CommitTimeGetter interface {
	GetCommitTime(hash string) (time.Time, error)
}

type Depl

type Depl struct {
	// Name is the name of the package depoyment.
	Name string
	// Def is the Forklift package deployment definition for the deployment.
	Def DeplDef
}

A Depl is a package deployment, a complete configuration of how a package is to be deployed on a Docker host.

func FilterDeplsForEnabled added in v0.4.0

func FilterDeplsForEnabled(depls []Depl) []Depl

FilterDeplsForEnabled filters a slice of Depls to only include those which are not disabled.

func (*Depl) ResAttachmentSource added in v0.2.0

func (d *Depl) ResAttachmentSource() []string

ResAttachmentSource returns the source path for resources under the Depl instance. The resulting slice is useful for constructing core.AttachedRes instances.

type DeplConflict added in v0.1.8

type DeplConflict struct {
	First  *ResolvedDepl
	Second *ResolvedDepl

	// Possible conflicts
	Name      bool
	Listeners []core.ResConflict[core.ListenerRes]
	Networks  []core.ResConflict[core.NetworkRes]
	Services  []core.ResConflict[core.ServiceRes]
	Filesets  []core.ResConflict[core.FilesetRes]
}

func CheckDeplConflicts added in v0.1.8

func CheckDeplConflicts(depls []*ResolvedDepl) (conflicts []DeplConflict, err error)

CheckDeplConflicts produces a slice of reports of all resource conflicts among all provided ResolvedDepl instances.

func (DeplConflict) HasConflict added in v0.1.8

func (c DeplConflict) HasConflict() bool

func (DeplConflict) HasFilesetConflict added in v0.5.2

func (c DeplConflict) HasFilesetConflict() bool

func (DeplConflict) HasListenerConflict added in v0.1.8

func (c DeplConflict) HasListenerConflict() bool

func (DeplConflict) HasNameConflict added in v0.1.8

func (c DeplConflict) HasNameConflict() bool

func (DeplConflict) HasNetworkConflict added in v0.1.8

func (c DeplConflict) HasNetworkConflict() bool

func (DeplConflict) HasServiceConflict added in v0.1.8

func (c DeplConflict) HasServiceConflict() bool

type DeplDef added in v0.1.8

type DeplDef struct {
	// Package is the package path of the package to deploy.
	Package string `yaml:"package"`
	// Features is a list of features from the package which should be enabled in the deployment.
	Features []string `yaml:"features"`
	// Disabled represents whether the deployment should be ignored.
	Disabled bool `yaml:"disabled"`
}

A DeplDef defines a package deployment.

type FSPallet added in v0.3.0

type FSPallet struct {
	// Pallet is the pallet at the root of the filesystem.
	Pallet
	// FS is a filesystem which contains the pallet's contents.
	FS core.PathedFS
}

A FSPallet is a Forklift pallet stored at the root of a fs.FS filesystem.

func LoadFSPallet added in v0.3.0

func LoadFSPallet(fsys core.PathedFS, subdirPath string) (p *FSPallet, err error)

LoadFSPallet loads a FSPallet from the specified directory path in the provided base filesystem.

func LoadFSPalletContaining added in v0.3.0

func LoadFSPalletContaining(path string) (*FSPallet, error)

LoadFSPalletContaining loads the FSPallet containing the specified sub-directory path in the provided base filesystem. The provided path should use the host OS's path separators. The sub-directory path does not have to actually exist.

func LoadFSPallets added in v0.6.0

func LoadFSPallets(fsys core.PathedFS, searchPattern string) ([]*FSPallet, error)

LoadFSPallets loads all FSPallets from the provided base filesystem matching the specified search pattern. The search pattern should be a doublestar pattern, such as `**`, matching pallet directories to search for. In the embedded Pallet of each loaded FSPallet, the version is *not* initialized.

func (*FSPallet) Exists added in v0.3.0

func (p *FSPallet) Exists() bool

Exists checks whether the pallet actually exists on the OS's filesystem.

func (*FSPallet) GetPalletReqsFS added in v0.6.0

func (p *FSPallet) GetPalletReqsFS() (core.PathedFS, error)

GetPalletReqsFS returns the fs.FS in the pallet which contains pallet requirement definitions.

func (*FSPallet) GetRepoReqsFS added in v0.3.0

func (p *FSPallet) GetRepoReqsFS() (core.PathedFS, error)

GetRepoReqsFS returns the fs.FS in the pallet which contains repo requirement definitions.

func (*FSPallet) LoadDepl added in v0.3.0

func (p *FSPallet) LoadDepl(name string) (depl Depl, err error)

LoadDepl loads the Depl with the specified name from the pallet.

func (*FSPallet) LoadDepls added in v0.3.0

func (p *FSPallet) LoadDepls(searchPattern string) ([]Depl, error)

LoadDepls loads all package deployment configurations matching the specified search pattern. The search pattern should not include the file extension for deployment specification files - the file extension will be appended to the search pattern by LoadDepls.

func (*FSPallet) LoadFSPalletReq added in v0.6.0

func (p *FSPallet) LoadFSPalletReq(palletPath string) (r *FSPalletReq, err error)

LoadFSPalletReq loads the FSPalletReq from the pallet for the pallet with the specified path.

func (*FSPallet) LoadFSPalletReqs added in v0.6.0

func (p *FSPallet) LoadFSPalletReqs(searchPattern string) ([]*FSPalletReq, error)

LoadFSPalletReqs loads all FSPalletReqs from the pallet matching the specified search pattern. The search pattern should be a doublestar pattern, such as `**`, matching the pallet paths to search for.

func (*FSPallet) LoadFSRepoReq added in v0.3.0

func (p *FSPallet) LoadFSRepoReq(repoPath string) (r *FSRepoReq, err error)

LoadFSRepoReq loads the FSRepoReq from the pallet for the repo with the specified path.

func (*FSPallet) LoadFSRepoReqs added in v0.3.0

func (p *FSPallet) LoadFSRepoReqs(searchPattern string) ([]*FSRepoReq, error)

LoadFSRepoReqs loads all FSRepoReqs from the pallet matching the specified search pattern. The search pattern should be a doublestar pattern, such as `**`, matching the repo paths to search for.

func (*FSPallet) LoadPkgReq added in v0.3.0

func (p *FSPallet) LoadPkgReq(pkgPath string) (r PkgReq, err error)

LoadPkgReq loads the PkgReq from the pallet for the package with the specified package path.

func (*FSPallet) LoadReadme added in v0.4.0

func (p *FSPallet) LoadReadme() ([]byte, error)

LoadReadme loads the readme file defined by the pallet.

func (*FSPallet) Path added in v0.4.0

func (p *FSPallet) Path() string

Path returns either the pallet's path (if specified) or its path on the filesystem.

func (*FSPallet) Remove added in v0.3.0

func (p *FSPallet) Remove() error

Remove deletes the cache from the OS's filesystem, if it exists.

type FSPalletCache added in v0.2.0

type FSPalletCache struct {
	// FS is the filesystem which corresponds to the cache of pallets.
	FS core.PathedFS
}

FSPalletCache is a PathedPalletCache implementation with copies of pallets stored in a core.PathedFS filesystem.

func (*FSPalletCache) Exists added in v0.2.0

func (c *FSPalletCache) Exists() bool

Exists checks whether the cache actually exists on the OS's filesystem.

func (*FSPalletCache) LoadFSPallet added in v0.2.0

func (c *FSPalletCache) LoadFSPallet(repoPath string, version string) (*FSPallet, error)

LoadFSPallet loads the FSPallet with the specified path and version. The loaded FSPallet instance is fully initialized.

func (*FSPalletCache) LoadFSPallets added in v0.2.0

func (c *FSPalletCache) LoadFSPallets(searchPattern string) ([]*FSPallet, error)

LoadFSPallets loads all FSPallets from the cache matching the specified search pattern. The search pattern should be a doublestar pattern, such as `**`, matching repo directories to search for. The loaded FSPallet instances are fully initialized.

func (*FSPalletCache) Path added in v0.2.0

func (c *FSPalletCache) Path() string

Path returns the path of the cache's filesystem.

func (*FSPalletCache) Remove added in v0.2.0

func (c *FSPalletCache) Remove() error

Remove deletes the cache from the OS's filesystem, if it exists.

type FSPalletLoader added in v0.2.0

type FSPalletLoader interface {
	// LoadFSPallet loads the FSPallet with the specified path and version.
	LoadFSPallet(palletPath string, version string) (*FSPallet, error)
	// LoadFSPallets loads all FSPallets matching the specified search pattern.
	LoadFSPallets(searchPattern string) ([]*FSPallet, error)
}

FSPalletLoader is a source of [FSPallet]s indexed by path and version.

type FSPalletReq added in v0.2.0

type FSPalletReq struct {
	// PalletReq is the pallet requirement at the root of the filesystem.
	PalletReq
	// FS is a filesystem which contains the pallet requirement's contents.
	FS core.PathedFS
}

A FSPalletReq is a pallet requirement stored at the root of a fs.FS filesystem.

type FSPkgLoader added in v0.1.8

type FSPkgLoader interface {
	// LoadFSPkg loads the FSPkg with the specified path and version.
	LoadFSPkg(pkgPath string, version string) (*core.FSPkg, error)
	// LoadFSPkgs loads all FSPkgs matching the specified search pattern.
	LoadFSPkgs(searchPattern string) ([]*core.FSPkg, error)
}

FSPkgLoader is a source of [core.FSPkg]s indexed by path and version.

type FSRepoCache added in v0.3.0

type FSRepoCache struct {
	// FS is the filesystem which corresponds to the cache of repos.
	FS core.PathedFS
}

FSRepoCache is a PathedRepoCache implementation with copies of repos (and thus of packages too) stored in a core.PathedFS filesystem.

func (*FSRepoCache) Exists added in v0.3.0

func (c *FSRepoCache) Exists() bool

Exists checks whether the cache actually exists on the OS's filesystem.

func (*FSRepoCache) LoadFSPkg added in v0.3.0

func (c *FSRepoCache) LoadFSPkg(pkgPath string, version string) (*core.FSPkg, error)

LoadFSPkg loads the FSPkg with the specified path and version. The loaded FSPkg instance is fully initialized.

func (*FSRepoCache) LoadFSPkgs added in v0.3.0

func (c *FSRepoCache) LoadFSPkgs(searchPattern string) ([]*core.FSPkg, error)

LoadFSPkgs loads all FSPkgs from the cache matching the specified search pattern. The search pattern should be a doublestar pattern, such as `**`, matching package directories to search for. The loaded FSPkg instances are fully initialized.

func (*FSRepoCache) LoadFSRepo added in v0.3.0

func (c *FSRepoCache) LoadFSRepo(repoPath string, version string) (*core.FSRepo, error)

LoadFSRepo loads the FSRepo with the specified path and version. The loaded FSRepo instance is fully initialized.

func (*FSRepoCache) LoadFSRepos added in v0.3.0

func (c *FSRepoCache) LoadFSRepos(searchPattern string) ([]*core.FSRepo, error)

LoadFSRepos loads all FSRepos from the cache matching the specified search pattern. The search pattern should be a doublestar pattern, such as `**`, matching repo directories to search for. The loaded FSRepo instances are fully initialized.

func (*FSRepoCache) Path added in v0.3.0

func (c *FSRepoCache) Path() string

Path returns the path of the cache's filesystem.

func (*FSRepoCache) Remove added in v0.3.0

func (c *FSRepoCache) Remove() error

Remove deletes the cache from the OS's filesystem, if it exists.

type FSRepoLoader added in v0.1.8

type FSRepoLoader interface {
	// LoadFSRepo loads the FSRepo with the specified path and version.
	LoadFSRepo(repoPath string, version string) (*core.FSRepo, error)
	// LoadFSRepos loads all FSRepos matching the specified search pattern.
	LoadFSRepos(searchPattern string) ([]*core.FSRepo, error)
}

FSRepoLoader is a source of [core.FSRepo]s indexed by path and version.

type FSRepoReq added in v0.1.8

type FSRepoReq struct {
	// RepoReq is the repo requirement at the root of the filesystem.
	RepoReq
	// FS is a filesystem which contains the repo requirement's contents.
	FS core.PathedFS
}

A FSRepoReq is a repo requirement stored at the root of a fs.FS filesystem.

type FSWorkspace added in v0.1.8

type FSWorkspace struct {
	FS core.PathedFS
}

func LoadWorkspace added in v0.1.8

func LoadWorkspace(dirPath string) (*FSWorkspace, error)

LoadWorkspace loads the workspace at the specified path. The workspace is usually just a home directory, e.g. $HOME; directories in the workspace are organized with the same structure as the default structure described by the [XDG base directory spec](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html). The provided path must use the host OS's path separators.

func (*FSWorkspace) GetCurrentPallet added in v0.3.0

func (w *FSWorkspace) GetCurrentPallet() (*FSPallet, error)

func (*FSWorkspace) GetCurrentPalletPath added in v0.3.0

func (w *FSWorkspace) GetCurrentPalletPath() string

func (*FSWorkspace) GetDataPath added in v0.6.0

func (w *FSWorkspace) GetDataPath() string

func (*FSWorkspace) GetPalletCache added in v0.2.0

func (w *FSWorkspace) GetPalletCache() (*FSPalletCache, error)

func (*FSWorkspace) GetPalletCachePath added in v0.2.0

func (w *FSWorkspace) GetPalletCachePath() string

func (*FSWorkspace) GetRepoCache added in v0.3.0

func (w *FSWorkspace) GetRepoCache() (*FSRepoCache, error)

func (*FSWorkspace) GetRepoCachePath added in v0.3.0

func (w *FSWorkspace) GetRepoCachePath() string

type GitRepoReq added in v0.6.0

type GitRepoReq struct {
	// GitRepoPath is the path of the required Git repository.
	RequiredPath string
	// VersionLock specifies the version of the required Git repository.
	VersionLock VersionLock
}

A GitRepoReq is a requirement for a specific Git repository (e.g. a pallet or Forklift repo) at a specific version.

func (GitRepoReq) GetQueryPath added in v0.6.0

func (r GitRepoReq) GetQueryPath() string

GetQueryPath returns the path of the Git repo in version queries, which is of form gitRepoPath@version (e.g. github.com/PlanktoScope/pallets/core@v0.1.0).

func (GitRepoReq) Path added in v0.6.0

func (r GitRepoReq) Path() string

Path returns the path of the required Git repo.

type LayeredPalletCache added in v0.2.0

type LayeredPalletCache struct {
	// Underlay is the underlying cache.
	Underlay PathedPalletCache
	// Overlay is the overlying cache which is used instead of the underlying cache for pallets
	// covered by the overlying cache.
	Overlay OverlayPalletCache
}

LayeredPalletCache is a PathedPalletCache implementation where selected pallets can be overridden by an OverlayPalletCache, for loading pallets. The path of the LayeredPalletCache instance is just the path of the underlying cache.

func (*LayeredPalletCache) LoadFSPallet added in v0.2.0

func (c *LayeredPalletCache) LoadFSPallet(repoPath string, version string) (*FSPallet, error)

LoadFSPallet loads the FSPallet with the specified path and version. The loaded FSPallet instance is fully initialized. If the overlay cache expects to have the repo, it will attempt to load the repo; otherwise, the underlay cache will attempt to load the repo.

func (*LayeredPalletCache) LoadFSPallets added in v0.2.0

func (c *LayeredPalletCache) LoadFSPallets(searchPattern string) ([]*FSPallet, error)

LoadFSPallets loads all FSPallets from the cache matching the specified search pattern. The search pattern should be a doublestar pattern, such as `**`, matching repo directories to search for. The loaded FSPallet instances are fully initialized. All matching repos from the overlay cache will be included; all matching repos from the underlay cache will also be included, except for those repos which the overlay cache expected to have.

func (*LayeredPalletCache) Path added in v0.2.0

func (c *LayeredPalletCache) Path() string

Path returns the path of the underlying cache.

type LayeredRepoCache added in v0.3.0

type LayeredRepoCache struct {
	// Underlay is the underlying cache.
	Underlay PathedRepoCache
	// Overlay is the overlying cache which is used instead of the underlying cache for repos and
	// packages covered by the overlying cache.
	Overlay OverlayRepoCache
}

LayeredRepoCache is a PathedRepoCache implementation where selected repos can be overridden by an OverlayRepoCache, for loading repos and packages. The path of the LayeredRepoCache instance is just the path of the underlying cache.

func (*LayeredRepoCache) LoadFSPkg added in v0.3.0

func (c *LayeredRepoCache) LoadFSPkg(pkgPath string, version string) (*core.FSPkg, error)

LoadFSPkg loads the FSPkg with the specified path and version. The loaded FSPkg instance is fully initialized. If the overlay cache expects to have the package, it will attempt to load the package; otherwise, the underlay cache will attempt to load the package.

func (*LayeredRepoCache) LoadFSPkgs added in v0.3.0

func (c *LayeredRepoCache) LoadFSPkgs(searchPattern string) ([]*core.FSPkg, error)

LoadFSPkgs loads all FSPkgs from the cache matching the specified search pattern. The search pattern should be a doublestar pattern, such as `**`, matching package directories to search for. The loaded FSPkg instances are fully initialized. All matching packages from the overlay cache will be included; all matching packages from the underlay cache will also be included, except for those packages which the overlay cache expected to have.

func (*LayeredRepoCache) LoadFSRepo added in v0.3.0

func (c *LayeredRepoCache) LoadFSRepo(
	repoPath string, version string,
) (*core.FSRepo, error)

LoadFSRepo loads the FSRepo with the specified path and version. The loaded FSRepo instance is fully initialized. If the overlay cache expects to have the repo, it will attempt to load the repo; otherwise, the underlay cache will attempt to load the repo.

func (*LayeredRepoCache) LoadFSRepos added in v0.3.0

func (c *LayeredRepoCache) LoadFSRepos(searchPattern string) ([]*core.FSRepo, error)

LoadFSRepos loads all FSRepos from the cache matching the specified search pattern. The search pattern should be a doublestar pattern, such as `**`, matching repo directories to search for. The loaded FSRepo instances are fully initialized. All matching repos from the overlay cache will be included; all matching repos from the underlay cache will also be included, except for those repos which the overlay cache expected to have.

func (*LayeredRepoCache) Path added in v0.3.0

func (c *LayeredRepoCache) Path() string

Path returns the path of the underlying cache.

type MissingDeplDeps added in v0.2.0

type MissingDeplDeps struct {
	Depl *ResolvedDepl

	Networks []core.MissingResDep[core.NetworkRes]
	Services []core.MissingResDep[core.ServiceRes]
	Filesets []core.MissingResDep[core.FilesetRes]
}

func (MissingDeplDeps) HasMissingDep added in v0.2.0

func (d MissingDeplDeps) HasMissingDep() bool

func (MissingDeplDeps) HasMissingFilesetDep added in v0.5.2

func (d MissingDeplDeps) HasMissingFilesetDep() bool

func (MissingDeplDeps) HasMissingNetworkDep added in v0.2.0

func (d MissingDeplDeps) HasMissingNetworkDep() bool

func (MissingDeplDeps) HasMissingServiceDep added in v0.2.0

func (d MissingDeplDeps) HasMissingServiceDep() bool

type OverlayPalletCache added in v0.2.0

type OverlayPalletCache interface {
	PalletCache
	// IncludesFSPallet reports whether the cache expects to have the specified pallet.
	// This result does not necessarily correspond to whether the cache actually has it.
	IncludesFSPallet(palletPath string, version string) bool
}

OverlayPalletCache is a PalletCache which can report whether it includes any particular pallet.

type OverlayRepoCache added in v0.3.0

type OverlayRepoCache interface {
	RepoCache
	// IncludesFSRepo reports whether the cache expects to have the specified repo.
	// This result does not necessarily correspond to whether the cache actually has it.
	IncludesFSRepo(repoPath string, version string) bool
	// IncludesFSPkg reports whether the cache expects to have the specified package.
	// This result does not necessarily correspond to whether the cache actually has it.
	IncludesFSPkg(pkgPath string, version string) bool
}

OverlayRepoCache is a RepoCache which can report whether it includes any particular repo or package.

type Pallet added in v0.3.0

type Pallet struct {
	// Def is the Forklift pallet definition for the pallet.
	Def PalletDef
	// Version is the version or pseudoversion of the pallet.
	Version string
}

A Pallet is a Forklift pallet, a complete specification of all package deployments which should be active on a Docker host.

func (Pallet) Check added in v0.6.0

func (p Pallet) Check() (errs []error)

Check looks for errors in the construction of the repo.

func (Pallet) Path added in v0.6.0

func (p Pallet) Path() string

Path returns the repo path of the Pallet instance.

func (Pallet) VersionQuery added in v0.6.0

func (p Pallet) VersionQuery() string

VersionQuery represents the Pallet instance as a version query.

type PalletCache added in v0.2.0

type PalletCache interface {
	FSPalletLoader
}

PalletCache is a source of pallets.

type PalletDef added in v0.3.0

type PalletDef struct {
	// ForkliftVersion indicates that the pallet was written assuming the semantics of a given version
	// of Forklift. The version must be a valid Forklift version, and it sets the minimum version of
	// Forklift required to use the pallet. The Forklift tool refuses to use pallets declaring newer
	// Forklift versions for any operations beyond printing information. The Forklift version of the
	// pallet must be greater than or equal to the Forklift version of every required Forklift repo or
	// pallet.
	ForkliftVersion string `yaml:"forklift-version"`
	// Pallet defines the basic metadata for the pallet.
	Pallet PalletSpec `yaml:"pallet,omitempty"`
}

A PalletDef defines a Forklift pallet.

func (PalletDef) Check added in v0.6.0

func (d PalletDef) Check() (errs []error)

Check looks for errors in the construction of the pallet configuration.

type PalletOverrideCache added in v0.2.0

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

PalletOverrideCache is an OverlayPalletCache implementation containing a set of pallets which can be retrieved from the root of the cache. A pallet from the cache will be retrieved if it is stored in the cache with a matching version, regardless of whether the pallet's own version actually matches - in other words, pallets can be stored with fictional versions.

func NewPalletOverrideCache added in v0.2.0

func NewPalletOverrideCache(
	overridePallets []*FSPallet, palletVersions map[string][]string,
) (*PalletOverrideCache, error)

NewPalletOverrideCache instantiates a new PalletOverrideCache with a given list of pallets, and a map associating pallet paths with lists of versions which the respective pallets will be associated with.

func (*PalletOverrideCache) IncludesFSPallet added in v0.2.0

func (c *PalletOverrideCache) IncludesFSPallet(palletPath string, version string) bool

IncludesFSPallet reports whether the PalletOverrideCache instance has a pallet with the specified path and version.

func (*PalletOverrideCache) LoadFSPallet added in v0.2.0

func (c *PalletOverrideCache) LoadFSPallet(palletPath string, version string) (*FSPallet, error)

LoadFSPallet loads the FSPallet with the specified path, if the version matches any of versions for the pallet in the cache. The loaded FSPallet instance is fully initialized.

func (*PalletOverrideCache) LoadFSPallets added in v0.2.0

func (c *PalletOverrideCache) LoadFSPallets(searchPattern string) ([]*FSPallet, error)

LoadFSPallets loads all FSPallets matching the specified search pattern. The search pattern should be a doublestar pattern, such as `**`, matching pallets to search for. The loaded FSPallet instances are fully initialized.

func (*PalletOverrideCache) SetVersions added in v0.2.0

func (c *PalletOverrideCache) SetVersions(palletPath string, versions map[string]struct{})

SetVersions configures the cache to cover the specified versions of the specified pallet.

type PalletReq added in v0.2.0

type PalletReq struct {
	GitRepoReq
}

A PalletReq is a requirement for a specific pallet at a specific version.

func (PalletReq) GetCachePath added in v0.2.0

func (r PalletReq) GetCachePath() string

GetCachePath returns the path of the pallet in caches, which is of form palletPath@version (e.g. github.com/PlanktoScope/pallets@v0.1.0/core).

func (PalletReq) GetQueryPath added in v0.2.0

func (r PalletReq) GetQueryPath() string

GetQueryPath returns the path of the pallet in version queries, which is of form palletPath@version (e.g. github.com/PlanktoScope/pallets/core@v0.1.0).

type PalletSpec added in v0.3.0

type PalletSpec struct {
	// Path is the pallet path, which acts as the canonical name for the pallet. It should just be the
	// path of the VCS repository for the pallet.
	Path string `yaml:"path"`
	// Description is a short description of the pallet to be shown to users.
	Description string `yaml:"description"`
	// ReadmeFile is the name of a readme file to be shown to users.
	ReadmeFile string `yaml:"readme-file"`
}

PalletSpec defines the basic metadata for a Forklift pallet.

func (PalletSpec) Check added in v0.6.0

func (s PalletSpec) Check() (errs []error)

Check looks for errors in the construction of the pallet spec.

type PathedPalletCache added in v0.2.0

type PathedPalletCache interface {
	PalletCache
	core.Pather
}

PathedPalletCache is a PalletCache rooted at a single path.

type PathedRepoCache added in v0.3.0

type PathedRepoCache interface {
	RepoCache
	core.Pather
}

PathedRepoCache is a RepoCache rooted at a single path.

type PkgReq added in v0.1.8

type PkgReq struct {
	// PkgSubdir is the package subdirectory in the repo which should provide the required package.
	PkgSubdir string
	// Repo is the repo which should provide the required package.
	Repo RepoReq
}

A PkgReq is a requirement for a package at a specific version.

func LoadRequiredFSPkg added in v0.1.8

func LoadRequiredFSPkg(
	pkgReqLoader PkgReqLoader, pkgLoader FSPkgLoader, pkgPath string,
) (*core.FSPkg, PkgReq, error)

LoadRequiredFSPkg loads the specified package from the cache according to the specifications in the package requirements provided by the package requirement loader for the provided package path.

func (PkgReq) GetCachePath added in v0.1.8

func (r PkgReq) GetCachePath() string

GetCachePath returns the path of the package in caches, which is of form repoPath@version/pkgSubdir (e.g. github.com/PlanktoScope/pallets@v0.1.0/core/infrastructure/caddy-ingress).

func (PkgReq) GetQueryPath added in v0.1.8

func (r PkgReq) GetQueryPath() string

GetQueryPath returns the path of the package in version queries, which is of form repoPath/pkgSubdir@version (e.g. github.com/PlanktoScope/pallets/core/infrastructure/caddy-ingress@v0.1.0).

func (PkgReq) Path added in v0.1.8

func (r PkgReq) Path() string

Path returns the package path of the required package.

type PkgReqLoader added in v0.1.8

type PkgReqLoader interface {
	LoadPkgReq(pkgPath string) (PkgReq, error)
}

PkgReqLoader is a source of package requirements.

type RepoCache added in v0.3.0

type RepoCache interface {
	FSRepoLoader
	FSPkgLoader
}

RepoCache is a source of repos and packages.

type RepoOverrideCache added in v0.1.8

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

RepoOverrideCache is an OverlayRepoCache implementation containing a set of repos which can be retrieved from the root of the cache. A repo from the cache will be retrieved if it is stored in the cache with a matching version, regardless of whether the repo's own version actually matches - in other words, repos can be stored with fictional versions.

func NewRepoOverrideCache added in v0.1.8

func NewRepoOverrideCache(
	overrideRepos []*core.FSRepo, repoVersions map[string][]string,
) (*RepoOverrideCache, error)

NewRepoOverrideCache instantiates a new RepoOverrideCache with a given list of repos, and a map associating repo paths with lists of versions which the respective repos will be associated with.

func (*RepoOverrideCache) IncludesFSPkg added in v0.1.8

func (c *RepoOverrideCache) IncludesFSPkg(pkgPath string, version string) bool

IncludesFSPkg reports whether the RepoOverrideCache instance has a repo with the specified version which covers the specified package path.

func (*RepoOverrideCache) IncludesFSRepo added in v0.1.8

func (c *RepoOverrideCache) IncludesFSRepo(repoPath string, version string) bool

IncludesFSRepo reports whether the RepoOverrideCache instance has a repo with the specified path and version.

func (*RepoOverrideCache) LoadFSPkg added in v0.1.8

func (c *RepoOverrideCache) LoadFSPkg(pkgPath string, version string) (*core.FSPkg, error)

LoadFSPkg loads the FSPkg with the specified path, if the version matches any of versions for the package's repo in the cache. The loaded FSPkg instance is fully initialized.

func (*RepoOverrideCache) LoadFSPkgs added in v0.1.8

func (c *RepoOverrideCache) LoadFSPkgs(searchPattern string) ([]*core.FSPkg, error)

LoadFSPkgs loads all FSPkgs matching the specified search pattern. The search pattern should be a doublestar pattern, such as `**`, matching package directories to search for. The loaded FSPkg instances are fully initialized.

func (*RepoOverrideCache) LoadFSRepo added in v0.1.8

func (c *RepoOverrideCache) LoadFSRepo(repoPath string, version string) (*core.FSRepo, error)

LoadFSRepo loads the FSRepo with the specified path, if the version matches any of versions for the repo in the cache. The loaded FSRepo instance is fully initialized.

func (*RepoOverrideCache) LoadFSRepos added in v0.1.8

func (c *RepoOverrideCache) LoadFSRepos(searchPattern string) ([]*core.FSRepo, error)

LoadFSRepos loads all FSRepos matching the specified search pattern. The search pattern should be a doublestar pattern, such as `**`, matching repos to search for. The loaded FSRepo instances are fully initialized.

func (*RepoOverrideCache) SetVersions added in v0.1.8

func (c *RepoOverrideCache) SetVersions(repoPath string, versions map[string]struct{})

SetVersions configures the cache to cover the specified versions of the specified repo.

type RepoReq added in v0.1.8

type RepoReq struct {
	GitRepoReq
}

A RepoReq is a requirement for a specific repo at a specific version.

func (RepoReq) GetCachePath added in v0.1.8

func (r RepoReq) GetCachePath() string

GetCachePath returns the path of the repo in caches, which is of form repoPath@version (e.g. github.com/PlanktoScope/pallets@v0.1.0/core).

func (RepoReq) GetPkgSubdir added in v0.1.8

func (r RepoReq) GetPkgSubdir(pkgPath string) string

GetPkgSubdir returns the package subdirectory within the required repo for the provided package path.

type ResolvedDepl added in v0.1.8

type ResolvedDepl struct {
	// Depl is the configured deployment of the package represented by Pkg.
	Depl
	// PkgReq is the package requirement for the deployment.
	PkgReq PkgReq
	// Pkg is the package to be deployed.
	Pkg *core.FSPkg
}

A ResolvedDepl is a deployment with a loaded package.

func ResolveDepl added in v0.1.8

func ResolveDepl(
	pkgReqLoader PkgReqLoader, pkgLoader FSPkgLoader, depl Depl,
) (resolved *ResolvedDepl, err error)

ResolveDepl loads the package from the FSPkgLoader instance based on the requirements in the provided deployment and the package requirement loader.

func ResolveDepls added in v0.1.8

func ResolveDepls(
	pkgReqLoader PkgReqLoader, pkgLoader FSPkgLoader, depls []Depl,
) (resolved []*ResolvedDepl, err error)

ResolveDepls loads the packages from the FSPkgLoader instance based on the requirements in the provided deployments and the package requirement loader.

func (*ResolvedDepl) Check added in v0.1.8

func (d *ResolvedDepl) Check() (errs []error)

func (*ResolvedDepl) CheckAllConflicts added in v0.1.8

func (d *ResolvedDepl) CheckAllConflicts(
	candidates []*ResolvedDepl,
) (conflicts []DeplConflict, err error)

CheckAllConflicts produces a slice of reports of all resource conflicts between the ResolvedDepl instance and each candidate ResolvedDepl.

func (*ResolvedDepl) CheckConflicts added in v0.1.8

func (d *ResolvedDepl) CheckConflicts(candidate *ResolvedDepl) (DeplConflict, error)

CheckConflicts produces a report of all resource conflicts between the ResolvedDepl instance and a candidate ResolvedDepl.

func (*ResolvedDepl) CheckDeps added in v0.2.0

func (d *ResolvedDepl) CheckDeps(
	candidates []*ResolvedDepl,
) (satisfied SatisfiedDeplDeps, missing MissingDeplDeps, err error)

CheckDeps produces a report of all resource requirements from the ResolvedDepl instance and which were and were not met by any candidate ResolvedDepl.

func (*ResolvedDepl) DefinesApp added in v0.4.0

func (d *ResolvedDepl) DefinesApp() (bool, error)

DefinesApp determines whether the deployment defines a Docker Compose app to be deployed.

func (*ResolvedDepl) DisabledFeatures added in v0.1.8

func (d *ResolvedDepl) DisabledFeatures() map[string]core.PkgFeatureSpec

DisabledFeatures returns a map of the package features not enabled by the deployment's configuration, with feature names as the keys of the map.

func (*ResolvedDepl) EnabledFeatures added in v0.1.8

func (d *ResolvedDepl) EnabledFeatures() (enabled map[string]core.PkgFeatureSpec, err error)

EnabledFeatures returns a map of the package features enabled by the deployment's configuration, with feature names as the keys of the map.

func (*ResolvedDepl) GetComposeFilenames added in v0.4.0

func (d *ResolvedDepl) GetComposeFilenames() ([]string, error)

GetComposeFilenames returns a list of the names of the Compose files which must be merged into the Compose app, with feature-flagged Compose files ordered based on the alphabetical order of enabled feature flags.

type SatisfiedDeplDeps added in v0.2.0

type SatisfiedDeplDeps struct {
	Depl *ResolvedDepl

	Networks []core.SatisfiedResDep[core.NetworkRes]
	Services []core.SatisfiedResDep[core.ServiceRes]
	Filesets []core.SatisfiedResDep[core.FilesetRes]
}

func (SatisfiedDeplDeps) HasSatisfiedDep added in v0.2.0

func (d SatisfiedDeplDeps) HasSatisfiedDep() bool

func (SatisfiedDeplDeps) HasSatisfiedFilesetDep added in v0.5.2

func (d SatisfiedDeplDeps) HasSatisfiedFilesetDep() bool

func (SatisfiedDeplDeps) HasSatisfiedNetworkDep added in v0.2.0

func (d SatisfiedDeplDeps) HasSatisfiedNetworkDep() bool

func (SatisfiedDeplDeps) HasSatisfiedServiceDep added in v0.2.0

func (d SatisfiedDeplDeps) HasSatisfiedServiceDep() bool

type VersionLock added in v0.1.8

type VersionLock struct {
	// Def is the version lock definition.
	Def VersionLockDef
	// Version is the version string corresponding to the configured version.
	Version string
}

A VersionLock is a specification of a particular version of a repo or package.

func (VersionLock) Check added in v0.1.8

func (l VersionLock) Check() (errs []error)

Check looks for errors in the construction of the version lock.

type VersionLockDef added in v0.1.8

type VersionLockDef struct {
	// Type specifies the type of version lock (either "version" or "pseudoversion")
	Type string `yaml:"type"`
	// Tag specifies the VCS repository tag associated with the version or pseudoversion, if it
	// exists. If the type is "version", the tag should point to the commit corresponding to the
	// version; if the type is "pseudoversion", the tag should be the highest-versioned tag in the
	// ancestry of the commit corresponding to the version (and it is used as a "base version").
	Tag string `yaml:"tag,omitempty"`
	// Timestamp specifies the commit time (in UTC) of the commit corresponding to the version, as
	// a 14-character string.
	Timestamp string `yaml:"timestamp"`
	// Commit specifies the full hash of the commit corresponding to the version.
	Commit string `yaml:"commit"`
}

A VersionLockDef defines a requirement for a repo or package at a specific version.

func (VersionLockDef) IsCommitLocked added in v0.1.8

func (l VersionLockDef) IsCommitLocked() bool

func (VersionLockDef) ParseVersion added in v0.1.8

func (l VersionLockDef) ParseVersion() (semver.Version, error)

func (VersionLockDef) Pseudoversion added in v0.1.8

func (l VersionLockDef) Pseudoversion() (string, error)

func (VersionLockDef) ShortCommit added in v0.1.8

func (l VersionLockDef) ShortCommit() string

func (VersionLockDef) Version added in v0.1.8

func (l VersionLockDef) Version() (string, error)

Directories

Path Synopsis
Package cli has shared utilities and application logic for the forklift CLI
Package cli has shared utilities and application logic for the forklift CLI

Jump to

Keyboard shortcuts

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