Documentation
¶
Overview ¶
package pack defines packaging format used by gravity
package pack implements simple package management capabilities
Index ¶
- Constants
- Variables
- func CheckUpdatePackage(from, to loc.Locator) error
- func ConfigLabels(loc loc.Locator, purpose string) map[string]string
- func ConfigurePackage(p PackageService, loc loc.Locator, confLoc loc.Locator, args []string, ...) error
- func CreateCertificateAuthority(p CreateCAParams) error
- func ExecutePackageCommand(p PackageService, cmd string, loc loc.Locator, confLoc *loc.Locator, ...) ([]byte, error)
- func FindConfigPackage(packages PackageService, filter loc.Locator) (*loc.Locator, error)
- func FindInstalledPackage(packages PackageService, filter loc.Locator) (*loc.Locator, error)
- func FindInstalledPackageWithConfig(packages PackageService, filter loc.Locator) (*loc.Locator, *loc.Locator, error)
- func FindLatestCompatiblePackage(packages PackageService, filter loc.Locator, version semver.Version) (*loc.Locator, error)
- func FindLatestPackage(packages PackageService, filter loc.Locator) (*loc.Locator, error)
- func FindLatestPackageByName(packages PackageService, name string) (*loc.Locator, error)
- func FindLatestPackagePredicate(packages PackageService, repository string, filter func(PackageEnvelope) bool) (*loc.Locator, error)
- func FindLatestPackageWithLabels(packages PackageService, repository string, labels map[string]string) (*loc.Locator, error)
- func FindNewerPackages(packages PackageService, filter loc.Locator) ([]loc.Locator, error)
- func FindPackageUpdate(packages PackageService, pkg loc.Locator) (*storage.PackageUpdate, error)
- func ForeachPackage(packages PackageService, fn func(e PackageEnvelope) error) error
- func ForeachPackageInRepo(packages PackageService, repo string, fn func(e PackageEnvelope) error) error
- func GetConfigPackage(p PackageService, loc loc.Locator, confLoc loc.Locator, args []string) (io.Reader, error)
- func HasCertificateAuthority(packages PackageService) (bool, error)
- func IsUnpacked(targetDir string) (bool, error)
- func PackagePath(baseDir string, loc loc.Locator) string
- func ProcessMetadata(packages PackageService, loc *loc.Locator) (*loc.Locator, error)
- func ReadCertificateAuthority(packages PackageService) (*authority.TLSKeyPair, error)
- func ReadConfigPackage(r io.Reader) (map[string]string, error)
- func ReadPackage(r io.Reader) (*Manifest, []PackageFile, error)
- func Tar(path string, checkManifest bool) (io.ReadCloser, error)
- func Unpack(p PackageService, loc loc.Locator, targetDir string, ...) error
- func UnpackIfNotUnpacked(p PackageService, loc loc.Locator, targetDir string, ...) error
- func WriteConfigPackage(m *Manifest, w io.Writer) error
- func WritePackage(m Manifest, w io.Writer, files []PackageFile) error
- type ACLService
- func (a *ACLService) CreatePackage(loc loc.Locator, data io.Reader, options ...PackageOption) (*PackageEnvelope, error)
- func (a *ACLService) DeletePackage(loc loc.Locator) error
- func (a *ACLService) DeleteRepository(repository string) error
- func (a *ACLService) GetPackages(repository string) ([]PackageEnvelope, error)
- func (a *ACLService) GetRepositories() ([]string, error)
- func (a *ACLService) GetRepository(repository string) (storage.Repository, error)
- func (a *ACLService) PackageDownloadURL(loc loc.Locator) string
- func (a *ACLService) PortalURL() string
- func (a *ACLService) ReadPackage(loc loc.Locator) (*PackageEnvelope, io.ReadCloser, error)
- func (a *ACLService) ReadPackageEnvelope(loc loc.Locator) (*PackageEnvelope, error)
- func (a *ACLService) UpdatePackageLabels(loc loc.Locator, addLabels map[string]string, removeLabels []string) error
- func (a *ACLService) UpsertPackage(loc loc.Locator, data io.Reader, options ...PackageOption) (*PackageEnvelope, error)
- func (a *ACLService) UpsertRepository(repository string, expires time.Time) error
- type Command
- type CreateCAParams
- type DiscardReporter
- type Label
- type Manifest
- type PackageEnvelope
- func (p *PackageEnvelope) HasAnyLabel(labels map[string][]string) bool
- func (p *PackageEnvelope) HasLabel(key, val string) bool
- func (p *PackageEnvelope) HasLabels(labels map[string]string) bool
- func (p PackageEnvelope) Options() []PackageOption
- func (p PackageEnvelope) String() string
- func (p PackageEnvelope) ToPackage() storage.Package
- func (p PackageEnvelope) ToPackagePtr() *storage.Package
- type PackageFile
- type PackageOption
- type PackageService
- type PackageSorter
- type ProgressReporter
- type ProgressReporterFn
- type ProgressWriter
- type Status
Constants ¶
const ( // CollectionRepositories means access on all repositories that exist CollectionRepositories = "repositories" // CollectionRepository means access on a particular repository CollectionRepository = "repository" )
const ( // InstalledLabel is used to mark installed packages InstalledLabel = "installed" // LatestLabel is a pseudo label that allows system to find the latest version LatestLabel = "latest" // ConfigLabel means that this is a configuration package for another package ConfigLabel = "config-package-for" // PurposeLabel describes the package purpose PurposeLabel = "purpose" // AdvertiseIPLabel contains advertise IP of the server the package is for AdvertiseIPLabel = "advertise-ip" // OperationIDLabel contains ID of the operation the package was configured for OperationIDLabel = "operation-id" // PurposeCA marks the planet certificate authority package PurposeCA = "ca" // PurposeExport marks the package with cluster export data PurposeExport = "export" // PurposeLicense marks the package with cluster license PurposeLicense = "license" // PurposeResources marks the package with user resources PurposeResources = "resources" // PurposePlanetSecrets marks packages with planet secrets PurposePlanetSecrets = "planet-secrets" // PurposePlanetConfig marks packages with planet config PurposePlanetConfig = "planet-config" // PurposeRuntime marks a package as a runtime container package PurposeRuntime = "runtime" // PurposeTeleportMasterConfig marks package with teleport master config PurposeTeleportMasterConfig = "teleport-master-config" // PurposeTeleportNodeConfig marks package with teleport node config PurposeTeleportNodeConfig = "teleport-node-config" // PurposeMetadata defines a label to use for application packages // that represent another package on a remote cluster. // A metadata package only contains a metadata block w/o actual contents of the // remote counterpart. PurposeMetadata = "metadata" // PurposeRPCCredentials marks a package as a package with agent RPC credentials PurposeRPCCredentials = "rpc-secrets" )
const ManifestFilename = "orbit.manifest.json"
ManifestFilename names the manifest file inside a package
const Version = "0.0.1"
Variables ¶
var InstalledLabels = map[string]string{ InstalledLabel: InstalledLabel, }
InstalledLabels defines a label set for an installed package
var LatestVersion = fmt.Sprintf("0.0.0+%v", LatestLabel)
LatestVersion is the meta version representing the latest version
var RuntimePackageLabels = map[string]string{ PurposeLabel: PurposeRuntime, }
RuntimePackageLabels identifies the runtime package
Functions ¶
func CheckUpdatePackage ¶
CheckUpdatePackage makes sure that "to" package is acceptable when updating from "from" package
func ConfigLabels ¶
ConfigLabels returns the label set to assign a configuration role for the specified package loc
func ConfigurePackage ¶
func ConfigurePackage(p PackageService, loc loc.Locator, confLoc loc.Locator, args []string, labels map[string]string) error
ConfigurePackage reads the given package, and configures it using arguments passed, the resulting package is created within the scope of the same package service
func CreateCertificateAuthority ¶
func CreateCertificateAuthority(p CreateCAParams) error
CreateCertificateAuthority creates the OpsCenter certificate authority package in the provided package service using the provided key pair
func ExecutePackageCommand ¶
func ExecutePackageCommand(p PackageService, cmd string, loc loc.Locator, confLoc *loc.Locator, execArgs []string, storageDir string) ([]byte, error)
ExecutePackageCommand executes command specified in the package and returns results of CombinedOutput call on the package binary
func FindConfigPackage ¶
FindConfigPackage returns configuration package for given package
func FindInstalledPackage ¶
FindInstalledPackage finds package currently installed on the host
func FindInstalledPackageWithConfig ¶
func FindInstalledPackageWithConfig(packages PackageService, filter loc.Locator) (*loc.Locator, *loc.Locator, error)
FindInstalledPackageWithConfig finds installed package and associated configuration package
func FindLatestCompatiblePackage ¶
func FindLatestCompatiblePackage(packages PackageService, filter loc.Locator, version semver.Version) (*loc.Locator, error)
FindLatestCompatiblePackage returns the latest compatible package for the provided filter and version
Two packages are deemed compatible when major and minor components of their semvers are the same.
func FindLatestPackage ¶
FindLatestPackage returns package the latest package matching the provided locator
func FindLatestPackageByName ¶
func FindLatestPackageByName(packages PackageService, name string) (*loc.Locator, error)
FindLatestPackageByName returns latest package with the specified name (across all repos)
func FindLatestPackagePredicate ¶
func FindLatestPackagePredicate(packages PackageService, repository string, filter func(PackageEnvelope) bool) (*loc.Locator, error)
FindLatestPackagePredicate returns the latest package matching the provided predicate function
If the provided repository is empty, searches all repositories.
func FindLatestPackageWithLabels ¶
func FindLatestPackageWithLabels(packages PackageService, repository string, labels map[string]string) (*loc.Locator, error)
FindLatestPackageWithLabels returns the latest package matching the provided labels
func FindNewerPackages ¶
FindNewerPackages returns packages with versions greater than in the provided package
func FindPackageUpdate ¶
func FindPackageUpdate(packages PackageService, pkg loc.Locator) (*storage.PackageUpdate, error)
FindPackageUpdate determines if an update is available for package specified with pkg and returns a descriptor object to go from existing version to a new one. If no update can be found, returns a nil descriptor and an instance of trace.NotFound as error
func ForeachPackage ¶
func ForeachPackage(packages PackageService, fn func(e PackageEnvelope) error) error
ForeachPackage executes function fn for each package in each repository
func ForeachPackageInRepo ¶
func ForeachPackageInRepo(packages PackageService, repo string, fn func(e PackageEnvelope) error) error
ForeachPackageInRepo executes fn for each package found in repository
func GetConfigPackage ¶
func GetConfigPackage(p PackageService, loc loc.Locator, confLoc loc.Locator, args []string) (io.Reader, error)
GetConfigPackage creates the config package without saving it into package service
func HasCertificateAuthority ¶
func HasCertificateAuthority(packages PackageService) (bool, error)
HasCertificateAuthority returns boolean indicating whether the provided package service has the OpsCenter certificate authority in it
func IsUnpacked ¶
IsUnpacked checks if the package has been unpacked at the provided directory (currently just by checking if the dir exists)
func PackagePath ¶
PackagePath generates a path to the package composed of base directory, repository name, package name and version
func ProcessMetadata ¶
ProcessMetadata processes some special metadata conventions, e.g. 'latest' metadata label
func ReadCertificateAuthority ¶
func ReadCertificateAuthority(packages PackageService) (*authority.TLSKeyPair, error)
ReadCertificateAuthority reads the OpsCenter certificate authority package from the provided package service and returns its key pair
func ReadPackage ¶
func ReadPackage(r io.Reader) (*Manifest, []PackageFile, error)
func Tar ¶
func Tar(path string, checkManifest bool) (io.ReadCloser, error)
Tar packs the directory into orbit archive. Manifest is always checked if present. If it's not present and checkManifest is set to false, orbit still packs the archive - manifests are optional
func Unpack ¶
func Unpack(p PackageService, loc loc.Locator, targetDir string, opts *dockerarchive.TarOptions) error
Unpack reads the package from the package service and unpacks its contents to base directory targetDir
func UnpackIfNotUnpacked ¶
func UnpackIfNotUnpacked(p PackageService, loc loc.Locator, targetDir string, opts *dockerarchive.TarOptions) error
UnpackIfNotUnpacked unpacks the specified package only if it's not yet unpacked
func WritePackage ¶
func WritePackage(m Manifest, w io.Writer, files []PackageFile) error
Types ¶
type ACLService ¶
type ACLService struct {
// contains filtered or unexported fields
}
ACLService is permission aware service that wraps regular service and applies checks before every operation
func (*ACLService) CreatePackage ¶
func (a *ACLService) CreatePackage(loc loc.Locator, data io.Reader, options ...PackageOption) (*PackageEnvelope, error)
CreatePackage creates package and adds it to to the existing repository
func (*ACLService) DeletePackage ¶
func (a *ACLService) DeletePackage(loc loc.Locator) error
DeletePackage deletes package from all repositories
func (*ACLService) DeleteRepository ¶
func (a *ACLService) DeleteRepository(repository string) error
DeleteRepository deletes repository - packages will remain in the packages repository
func (*ACLService) GetPackages ¶
func (a *ACLService) GetPackages(repository string) ([]PackageEnvelope, error)
GetPackages returns a list of packages in repository
func (*ACLService) GetRepositories ¶
func (a *ACLService) GetRepositories() ([]string, error)
Get repositories returns a list of repositories
func (*ACLService) GetRepository ¶
func (a *ACLService) GetRepository(repository string) (storage.Repository, error)
GetRepository returns repository by name, returns error if it does not exist
func (*ACLService) PackageDownloadURL ¶
func (a *ACLService) PackageDownloadURL(loc loc.Locator) string
func (*ACLService) PortalURL ¶
func (a *ACLService) PortalURL() string
func (*ACLService) ReadPackage ¶
func (a *ACLService) ReadPackage(loc loc.Locator) (*PackageEnvelope, io.ReadCloser, error)
Read package opens and returns package contents
func (*ACLService) ReadPackageEnvelope ¶
func (a *ACLService) ReadPackageEnvelope(loc loc.Locator) (*PackageEnvelope, error)
ReadPackageEnvelope returns package envelope
func (*ACLService) UpdatePackageLabels ¶
func (*ACLService) UpsertPackage ¶
func (a *ACLService) UpsertPackage(loc loc.Locator, data io.Reader, options ...PackageOption) (*PackageEnvelope, error)
UpsertPackage creates package and adds it to to the existing repository
func (*ACLService) UpsertRepository ¶
func (a *ACLService) UpsertRepository(repository string, expires time.Time) error
type CreateCAParams ¶
type CreateCAParams struct {
// Packages is the package service to create the package in
Packages PackageService
// KeyPair is the CA certificate / key pair
KeyPair authority.TLSKeyPair
// Upsert if true upserts the package
Upsert bool
}
CreateCAParams combines parameters for creating a CA package
type DiscardReporter ¶
type DiscardReporter struct {
}
DiscardReporter discards report progress
func (*DiscardReporter) Report ¶
func (f *DiscardReporter) Report(current, target int64)
Report of DiscardReporter does nothing
type Manifest ¶
type Manifest struct {
Version string `json:"version"`
Config *schema.Config `json:"config,omitempty"`
Commands []Command `json:"commands,omitempty"`
Labels []Label `json:"labels,omitempty"`
Service *systemservice.NewPackageServiceRequest `json:"service,omitempty"`
}
func GetPackageManifest ¶
func GetPackageManifest(p PackageService, loc loc.Locator) (*Manifest, error)
GetPackageManifest will retrieve the manifest file for the specified package
func OpenManifest ¶
func ReadManifest ¶
ReadManifest returns the contents of the manifest file from the specified tarball
func (*Manifest) EncodeJSON ¶
func (*Manifest) NeedsConfig ¶
type PackageEnvelope ¶
type PackageEnvelope struct {
// Locator references the package
Locator loc.Locator `json:"locator"`
// SizeBytes is the size of the package in bytes
SizeBytes int64 `json:"size_bytes"`
// SHA512 specifies the sha-512 checksum of the package contents
SHA512 string `json:"sha512"`
// RuntimeLabels specifies a set of labels attached to the package
RuntimeLabels map[string]string `json:"runtime_labels"`
// Hidden is whether the package should not be displayed
Hidden bool `json:"hidden"`
// Encrypted is whether the package is encrypted
Encrypted bool `json:"encrypted"`
// Type specifies the application package type.
// Empty for regular packages
Type string `json:"type"`
// Manifest contains the base64-encoded application manifest
Manifest []byte `json:"manifest"`
// Created specifies the package creation timestamp
Created time.Time `json:"created"`
// CreatedBy specifies the package creator
CreatedBy string `json:"created_by"`
}
PackageEnvelope returns extended information about a package, such as name, version ,size in bytes, hash, manifest and date and time it was created and list of tags
func FindPackage ¶
func FindPackage(packages PackageService, fn func(e PackageEnvelope) bool) (*PackageEnvelope, error)
FindPackage finds package matching the predicate fn
func (*PackageEnvelope) HasAnyLabel ¶
func (p *PackageEnvelope) HasAnyLabel(labels map[string][]string) bool
HasAnyLabel returns true if envelope has any of the provided labels
func (*PackageEnvelope) HasLabel ¶
func (p *PackageEnvelope) HasLabel(key, val string) bool
HasLabel returns true if envelope has the requested label
func (*PackageEnvelope) HasLabels ¶
func (p *PackageEnvelope) HasLabels(labels map[string]string) bool
HasLabels returns true if envelope has all of the provided labels
func (PackageEnvelope) Options ¶
func (p PackageEnvelope) Options() []PackageOption
Options returns a list of options for this package envelope
func (PackageEnvelope) String ¶
func (p PackageEnvelope) String() string
func (PackageEnvelope) ToPackage ¶
func (p PackageEnvelope) ToPackage() storage.Package
ToPackage converts package envelope to the storage package format
func (PackageEnvelope) ToPackagePtr ¶
func (p PackageEnvelope) ToPackagePtr() *storage.Package
ToPackagePtr converts package envelope to the storage package format
type PackageFile ¶
type PackageOption ¶
PackageOption is a function that can make attribute modifications to the specified package
func WithCreatedBy ¶
func WithCreatedBy(createdBy string) PackageOption
WithCreatedBy configures the package creator
func WithEncrypted ¶
func WithEncrypted(encrypted bool) PackageOption
WithEncrypted configures the encryption status of a package
func WithHidden ¶
func WithHidden(hidden bool) PackageOption
WithHidden configures a hidden flag for a package
func WithLabels ¶
func WithLabels(labels map[string]string) PackageOption
WithLabels adds the specified labels as runtime labels to a package
func WithManifest ¶
func WithManifest(packageType string, manifest []byte) PackageOption
WithManifest configures application-specific attributes like type and manifest for a package
type PackageService ¶
type PackageService interface {
// PackageDownloadURL returns download url for this package
PackageDownloadURL(loc loc.Locator) string
// PortalURL returns url for this portal
PortalURL() string
// UpsertRepository creates or updates repository, if expires is not
// zero time the repository and all packages will be set to be expired
UpsertRepository(repository string, expires time.Time) error
// DeleteRepository deletes repository - packages will remain in the
// packages repository
DeleteRepository(repository string) error
// GetRepository returns repository by name
GetRepository(repository string) (storage.Repository, error)
// Get repositories returns a list of repositories
GetRepositories() ([]string, error)
// GetPackages returns a list of packages in repository
GetPackages(repository string) ([]PackageEnvelope, error)
// CreatePackage creates package and adds it to to the existing repository
CreatePackage(loc loc.Locator, data io.Reader, options ...PackageOption) (*PackageEnvelope, error)
// UpsertPackage creates or updates package and adds it to to the existing repository
UpsertPackage(loc loc.Locator, data io.Reader, options ...PackageOption) (*PackageEnvelope, error)
// UpdatePackageLabels updates package's labels
UpdatePackageLabels(loc loc.Locator, addLabels map[string]string, removeLabels []string) error
// DeletePackage deletes package from repository
DeletePackage(locator loc.Locator) error
// Read package opens and returns package contents
ReadPackage(loc loc.Locator) (*PackageEnvelope, io.ReadCloser, error)
// ReadPackageEnvelope returns package envelope
ReadPackageEnvelope(loc loc.Locator) (*PackageEnvelope, error)
}
func PackagesWithACL ¶
func PackagesWithACL(packages PackageService, users users.Users, user storage.User, checker teleservices.AccessChecker) PackageService
type PackageSorter ¶
type PackageSorter []PackageEnvelope
PackageSorter is a package sort helper, is used to return deterministic results by lexicographically sorting packages
func (PackageSorter) Len ¶
func (s PackageSorter) Len() int
func (PackageSorter) Less ¶
func (s PackageSorter) Less(i, j int) bool
func (PackageSorter) Swap ¶
func (s PackageSorter) Swap(i, j int)
type ProgressReporter ¶
type ProgressReporter interface {
Report(current, target int64)
}
type ProgressReporterFn ¶
type ProgressReporterFn func(current, target int64)
func (ProgressReporterFn) Report ¶
func (f ProgressReporterFn) Report(current, target int64)
type ProgressWriter ¶
type ProgressWriter struct {
Size int64
R ProgressReporter
// contains filtered or unexported fields
}
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package suite contains a package service acceptance test suite that is backend implementation independent each storage will use the suite to test itself
|
Package suite contains a package service acceptance test suite that is backend implementation independent each storage will use the suite to test itself |