loc

package
v0.0.0-...-3bfe646 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2023 License: Apache-2.0 Imports: 11 Imported by: 21

Documentation

Index

Constants

View Source
const (
	// ZeroVersion is a special "zero" package version that means "no particular version"
	ZeroVersion = "0.0.0"

	// FirstVersion is a special package version that indicates the initial package version
	FirstVersion = "0.0.1"

	// LatestVersion defines a special placeholder for greatest available version
	LatestVersion = "0.0.0+latest"

	// StableVersion defines a special placeholder for the latest stable version
	StableVersion = "0.0.0+stable"
)

Variables

View Source
var (
	// OpsCenterCertificateAuthority is locator for the package containing certificate and private
	// key for the OpsCenter
	OpsCenterCertificateAuthority = MustParseLocator(
		fmt.Sprintf("%v/%v:0.0.1", defaults.SystemAccountOrg, constants.OpsCenterCAPackage))

	// Runtime is the default runtime application locator
	Runtime = MustParseLocator(
		fmt.Sprintf("%v/%v:%v", defaults.SystemAccountOrg, defaults.Runtime, LatestVersion))

	// Bandwagon is the bandwagon application locator
	Bandwagon = MustParseLocator(
		fmt.Sprintf("%v/%v:%v", defaults.SystemAccountOrg, defaults.BandwagonPackageName, LatestVersion))

	// Planet is the planet package locator
	Planet = MustParseLocator(
		fmt.Sprintf("%v/%v:%v", defaults.SystemAccountOrg, constants.PlanetPackage, ZeroVersion))

	// Teleport is the teleport package locator
	Teleport = MustParseLocator(
		fmt.Sprintf("%v/%v:%v", defaults.SystemAccountOrg, constants.TeleportPackage, ZeroVersion))

	// Gravity is the gravity binary package locator
	Gravity = MustParseLocator(
		fmt.Sprintf("%v/%v:%v", defaults.SystemAccountOrg, constants.GravityPackage, ZeroVersion))

	// Fio is the fio binary package locator
	Fio = MustParseLocator(
		fmt.Sprintf("%v/%v:%v", defaults.SystemAccountOrg, constants.FioPackage, ZeroVersion))

	// TrustedCluster is the trusted-cluster package locator
	TrustedCluster = MustParseLocator(
		fmt.Sprintf("%v/%v:0.0.1", defaults.SystemAccountOrg, constants.TrustedClusterPackage))

	// RPCSecrets defines a package with RPC agent credentials
	// that the wizard and cluster controller create.
	// The credentials are then pulled by agents that participate in installation
	// and join/leave operations.
	RPCSecrets = MustParseLocator(
		fmt.Sprintf("%v/%v:0.0.1", defaults.SystemAccountOrg, defaults.RPCAgentSecretsPackage))

	// LegacyPlanetMaster is the package locator for legacy planet master packages
	LegacyPlanetMaster = MustParseLocator(
		fmt.Sprintf("%v/%v:%v", defaults.SystemAccountOrg, "planet-master", ZeroVersion))

	// LegacyPlanetNode is the package locator for legacy planet node packages
	LegacyPlanetNode = MustParseLocator(
		fmt.Sprintf("%v/%v:%v", defaults.SystemAccountOrg, "planet-node", ZeroVersion))

	// WebAssetsPackageLocator is the package with web assets
	WebAssetsPackageLocator = MustParseLocator(
		fmt.Sprintf("%v/%v:%v", defaults.SystemAccountOrg, "web-assets", ZeroVersion))
)

Functions

func Contains

func Contains(locator Locator, locators []Locator) bool

Contains checks if a list of locators contains another one

func GreaterOrEqualPatch

func GreaterOrEqualPatch(left, right semver.Version) bool

GreaterOrEqualPatch returns true if the left version has the same major/minor components as the right version but a greater or equal patch component.

func IsLegacyRuntimePackage

func IsLegacyRuntimePackage(loc Locator) bool

IsLegacyRuntimePackage returns true if the specified package envelope describes a legacy runtime package TODO: remove when there's no more need to take legacy runtime packages into account

func IsSameApp

func IsSameApp(app1, app2 Locator) bool

IsSameApp returns true if the provided locators have the same repository and name

func IsUpdate

func IsUpdate(update Locator, installed []Locator) (bool, error)

IsUpdate returns true if the specified locator is of newer version than the one in the provided list, or if it's missing from the list (meaning it's a new package)

Types

type Digest

type Digest struct {
	Type string
	Hash []byte
}

func NewDigest

func NewDigest(t string, val []byte) (*Digest, error)

func NewDigestFromHex

func NewDigestFromHex(t string, val string) (*Digest, error)

func (Digest) Hex

func (d Digest) Hex() string

func (Digest) String

func (d Digest) String() string

type DockerImage

type DockerImage struct {
	Registry   string `json:"registry"`
	Repository string `json:"repository"`
	Tag        string `json:"tag"`
	Digest     string `json:"digest"`
}

func ParseDockerImage

func ParseDockerImage(image string) (*DockerImage, error)

func (*DockerImage) String

func (d *DockerImage) String() string

String returns the string representation of the DockerImage. Format: [Registry/]Repository[:Tag][@Digest]

type DockerImages

type DockerImages []DockerImage

DockerImages represent a slice of DockerImage.

func ImagesSlice

func ImagesSlice(s kingpin.Settings) *DockerImages

ImagesSlice creates a collection of DockerImages from a kingpin command line argument.

func (*DockerImages) IsCumulative

func (*DockerImages) IsCumulative() bool

IsCumulative indicates that DockerImages is a cumulative argument.

func (*DockerImages) Set

func (i *DockerImages) Set(v string) error

Set sets the value of a DockerImage if the supplied string is a valid image locator, returning any errors encountered.

func (*DockerImages) String

func (i *DockerImages) String() string

String returns a string representation of the DockerImages type.

type Locator

type Locator struct {
	Repository string `json:"repository"` // package software repository
	Name       string `json:"name"`       // example: "planet-dev"
	Version    string `json:"version"`    // example: "0.0.36"
}

Locator is a unique package locator. It consists of the name and version in the form of sem ver

func Deduplicate

func Deduplicate(ls []Locator) (result []Locator)

Deduplicate returns ls with duplicates removed

func Filter

func Filter(locators []Locator, filters []Locator, message string) (result []Locator)

Filter filters a list of locators. Excludes the values specified in []filters from []locators.

func MakeLocator

func MakeLocator(app string) (*Locator, error)

MakeLocator takes an app package and makes a locator out of it:

  • if it's in the 'repo/name:ver' format, returns it
  • if it's in the 'name:ver' format, returns locator with system repo (systemrepo/name:ver)
  • if it's in the 'name' format, returns locator with system repo and latest meta-version (systemrepo/name:0.0.0+latest)

func MakeLocatorWithDefault

func MakeLocatorWithDefault(app string, defaultVersion defaultVersionFunc) (*Locator, error)

MakeLocatorWithDefault is like MakeLocator but uses the provided default version if the one isn't specified explicitly, instead of defaulting to the latest.

func MustCreateLocator

func MustCreateLocator(repo, name, ver string) Locator

MustCreateLocator creates new locator from parts or panics

func MustParseLocator

func MustParseLocator(v string) Locator

func NewLocator

func NewLocator(repository, name, ver string) (*Locator, error)

func ParseLocator

func ParseLocator(v string) (*Locator, error)

func (*Locator) IsEmpty

func (l *Locator) IsEmpty() bool

IsEmpty returns true if locator presents empty value

func (Locator) IsEqualTo

func (l Locator) IsEqualTo(other Locator) bool

IsEqualTo returns true if this locator is equal to the other

func (*Locator) IsNewerThan

func (l *Locator) IsNewerThan(other Locator) (bool, error)

IsNewerThan returns true if this locator is of greater version than the provided locator

func (*Locator) SemVer

func (l *Locator) SemVer() (*semver.Version, error)

SemVer obtains emver from a marshalled version

func (*Locator) Set

func (l *Locator) Set(v string) error

func (Locator) String

func (l Locator) String() string

String returns the locator's string representation.

func (Locator) WithLiteralVersion

func (l Locator) WithLiteralVersion(version string) Locator

WithLiteralVersion returns a copy of this locator with version set to the specified one

func (Locator) WithVersion

func (l Locator) WithVersion(version *semver.Version) Locator

WithVersion returns a copy of this locator with version set to the specified one

func (*Locator) ZeroVersion

func (l *Locator) ZeroVersion() Locator

ZeroVersion returns a special 0.0.0 version of the package

type Locators

type Locators []Locator

Locators represents a list of package locators.

func LocatorSlice

func LocatorSlice(s kingpin.Settings) *Locators

LocatorSlice creates a collection of Locators from a kingpin command line argument.

func (*Locators) IsCumulative

func (*Locators) IsCumulative() bool

IsCumulative indicates that Locators is a cumulative argument.

func (*Locators) Set

func (l *Locators) Set(v string) error

Set sets the value of a Locator if the supplied string is a valid locator, returning any errors encountered.

func (*Locators) String

func (l *Locators) String() string

String returns a string representation of the Locators type.

Jump to

Keyboard shortcuts

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