versioneer

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: Apache-2.0 Imports: 10 Imported by: 1

README

_ -eer suffix : (in nouns) a person concerned with a particular thing` (https://www.oxfordlearnersdictionaries.com)

Versioneer is a library and a wrapping cli that is concerned with everything related to artifact names and versions in Kairos.

There is a standalone CLI in the bin/versioneer directory of thie repository. It's also embedded in kairos-agent as a command "kairos-agent versioneer". This allows to use it wherever we have kairos-agent available (e.g. within a Kairos OS) or inside Earthly (by running the standalone cli in an Earthly target).

Documentation

Index

Constants

View Source
const (
	// KAIROS_VERSION was already used in os-release and we avoided breaking it
	// for consumers by using a new variable KAIROS_RELEASE instead. But it's the
	// "Artifact.Version".
	EnvVarVersion               = "RELEASE"
	EnvVarFlavor                = "FLAVOR"
	EnvVarFlavorRelease         = "FLAVOR_RELEASE"
	EnvVarVariant               = "VARIANT"
	EnvVarModel                 = "MODEL"
	EnvVarArch                  = "TARGETARCH"
	EnvVarSoftwareVersion       = "SOFTWARE_VERSION"
	EnvVarSoftwareVersionPrefix = "SOFTWARE_VERSION_PREFIX"
	EnvVarRegistryAndOrg        = "REGISTRY_AND_ORG"
	EnvVarID                    = "ID"
	EnvVarGithubRepo            = "GITHUB_REPO"
	EnvVarBugReportURL          = "BUG_REPORT_URL"
	EnvVarHomeURL               = "HOME_URL"
	EnvVarFamily                = "FAMILY"
)

Variables

This section is empty.

Functions

func CliCommands

func CliCommands() []*cli.Command

Types

type Artifact

type Artifact struct {
	Flavor                string
	Family                string
	FlavorRelease         string
	Variant               string
	Model                 string
	Arch                  string
	Version               string // The Kairos version. E.g. "v2.4.2"
	SoftwareVersion       string // The k3s version. E.g. "v1.26.9+k3s1"
	SoftwareVersionPrefix string // E.g. k3s
	RegistryInspector     RegistryInspector
}

func NewArtifactFromJSON

func NewArtifactFromJSON(jsonStr string) (*Artifact, error)

func NewArtifactFromOSRelease

func NewArtifactFromOSRelease(file ...string) (*Artifact, error)

NewArtifactFromOSRelease generates an artifact by inpecting the variables in the /etc/os-release file of a Kairos image. The variable should be prefixed with "KAIROS_". E.g. KAIROS_VARIANT would be used to set the Variant field. The function optionally takes an argument to specify a different file path (for testing reasons).

func (*Artifact) BaseContainerName

func (a *Artifact) BaseContainerName(registryAndOrg, id string) (string, error)

func (*Artifact) BaseTag

func (a *Artifact) BaseTag() (string, error)

func (*Artifact) BootableName

func (a *Artifact) BootableName() (string, error)

func (*Artifact) ContainerName

func (a *Artifact) ContainerName(registryAndOrg string) (string, error)

func (*Artifact) OSReleaseVariables

func (a *Artifact) OSReleaseVariables(registryAndOrg, githubRepo, bugURL, homeURL string) (string, error)

OSReleaseVariables returns a set of variables to be appended in /etc/os-release

func (*Artifact) Repository added in v0.0.19

func (a *Artifact) Repository(registryAndOrg string) string

func (*Artifact) SoftwareVersionForTag added in v0.0.19

func (a *Artifact) SoftwareVersionForTag() string

SoftwareVersionForTag replaces and "+" symbols with "-" because in container image tags, "+" is not valid

func (*Artifact) Tag

func (a *Artifact) Tag() (string, error)

func (*Artifact) TagList

func (a *Artifact) TagList(registryAndOrg string) (TagList, error)

func (*Artifact) Validate

func (a *Artifact) Validate() error

func (*Artifact) ValidateBase added in v0.0.22

func (a *Artifact) ValidateBase() error

func (*Artifact) VersionForTag added in v0.0.19

func (a *Artifact) VersionForTag() string

VersionForTag replaces and "+" symbols with "-" because in container image tags, "+" is not valid

type DefaultRegistryInspector

type DefaultRegistryInspector struct{}

func (*DefaultRegistryInspector) TagList

func (i *DefaultRegistryInspector) TagList(registryAndOrg string, artifact *Artifact) (TagList, error)

type RegistryInspector

type RegistryInspector interface {
	TagList(registryAndOrg string, artifact *Artifact) (TagList, error)
}

type TagList

type TagList struct {
	Tags           []string
	Artifact       *Artifact
	RegistryAndOrg string
}

func (TagList) FullImages added in v0.0.19

func (tl TagList) FullImages() ([]string, error)

FullImages returns a slice of strings which has the tags converts to full image URLs (not just tags).

func (TagList) Images

func (tl TagList) Images() TagList

Images returns only tags that represent images, skipping tags representing: - sbom - att - sig - -img

func (TagList) Len

func (tl TagList) Len() int

implements sort.Interface for TagList

func (TagList) Less

func (tl TagList) Less(i, j int) bool

func (TagList) NewerAnyVersion

func (tl TagList) NewerAnyVersion() TagList

NewerAnyVersion returns tags with:

  • a kairos version newer than the given artifact's
  • a kairos version same as the given artifacts but a software version higher than the current artifact's

Splitting the 2 versions is done using the artifact's SoftwareVersionPrefix (first encountered, because our tags have a "k3s1" in the end too)

func (TagList) NewerSofwareVersions

func (tl TagList) NewerSofwareVersions() TagList

NewerSofwareVersions returns OtherSoftwareVersions filtered to only include tags with SoftwareVersion higher than the given artifact's.

func (TagList) NewerVersions

func (tl TagList) NewerVersions() TagList

NewerVersions returns OtherVersions filtered to only include tags with Version higher than the given artifact's.

func (TagList) NoPrereleases added in v0.0.19

func (tl TagList) NoPrereleases() TagList

NoPrereleases returns only tags in which Version is not a pre-release (as defined by semver). NOTE: We only filter out Kairos prereleases because the k3s version is not semver anyway. The upstream version is something like: v1.28.3+k3s2 The first part is semver and it's the Kubernetes version and the "+k3s2" part is the k3s version which has changes over "k3s1" (it's not just a new build of the same thing)(https://github.com/k3s-io/k3s/releases/tag/v1.28.3%2Bk3s2) To make things more complicated, when we create a container image tag, we convert "+" to "-" because tags don't allow "+" symbols. This makes every k3s version look like a pre-release according to semver.

func (TagList) OtherAnyVersion

func (tl TagList) OtherAnyVersion() TagList

OtherAnyVersion returns tags that match all fields of the given Artifact, except the SoftwareVersion and/or Version. Should be used to return tags with newer versions (Kairos or "software") that one could upgrade to. This method returns all versions, not only newer ones. Use NewerAnyVersion to fetch only versions, newer than the one of the Artifact.

func (TagList) OtherSoftwareVersions

func (tl TagList) OtherSoftwareVersions() TagList

OtherSoftwareVersions returns tags that match all fields of the given Artifact, except the SoftwareVersion. Should be used to return other possible software versions for the same Kairos image (e.g. that one could upgrade to). This method returns all versions, not only newer ones. Use NewerSofwareVersions to fetch only versions, newer than the one of the Artifact.

func (TagList) OtherVersions

func (tl TagList) OtherVersions() TagList

OtherVersions returns tags that match all fields of the given Artifact, except the Version. Should be used to return other possible versions for the same Kairos image (e.g. that one could upgrade to). This method returns all versions, not only newer ones. Use NewerVersions to fetch only versions, newer than the one of the Artifact.

func (TagList) Print

func (tl TagList) Print()

func (TagList) PrintImages added in v0.0.19

func (tl TagList) PrintImages()

func (TagList) RSorted

func (tl TagList) RSorted() TagList

RSorted returns the TagList in the reverse order of Sorted This means higher versions come first.

func (TagList) Sorted

func (tl TagList) Sorted() TagList

Sorted returns the TagList sorted by semver. This means lower versions come first.

func (TagList) Swap

func (tl TagList) Swap(i, j int)

Jump to

Keyboard shortcuts

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