Documentation ¶
Overview ¶
Package tagcmp provides image tag comparison operations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var CommitHashPattern = "^[a-f0-9]{7,40}$"
CommitHashPattern matches commit-like hash tags
var DotPattern = "([0-9]+)\\.([0-9]+)"
DotPattern matches tags which contain multiple versions
var EmptyPattern = "^$"
EmptyPattern matches when tags are missing
var ParametrizedPattern = "\\${.+}"
ParametrizedPattern matches when tags are parametrized
var StringPattern = "^[a-zA-Z]+$"
StringPattern matches when tags are only made up of alphabetic characters
Functions ¶
func IsParsable ¶
IsParsable determines if a tag is supported by this library
Types ¶
type ByTagAsc ¶
type ByTagAsc []Tag
ByTagAsc sorts tags in ascending order where the last element is the latest tag.
type ByTagDesc ¶
type ByTagDesc []Tag
ByTagDesc sorts tags in descending order where the first element is the latest tag.
type Tag ¶
type Tag struct { Major string `json:",omitempty"` // major semver part Minor string `json:",omitempty"` // minor semver part MissingMinor bool // whether or not the minor semver part was left out Patch string `json:",omitempty"` // patch semver part MissingPatch bool // whether or not he patch semver part was left out Suffix string // tag suffix (e.g. "-alpine") [would be release candidate in semver] UsesV bool // whether or not the tag uses the "v" prefix Metadata string // metadata: what's after + and after the first "-" }
func Parse ¶
Parse converts an image tag into a structured data format. It aims to to support the general case of tags which are "semver-like" and/or stable and parseable by heuristics. Image tags follow no formal specification and therefore this is a best-effort implementation. Examples of tags this function can parse are: "5", "5.2", "v4", "v5.3.6", "4-alpine", "v3.2.1-debian".
func (Tag) IsCompatible ¶
IsCompatible determines if two tags can be compared together
func (Tag) IsGreaterThan ¶
IsGreaterThan tests if a tag is greater than another. There are some tag-isms to take into account here, shorter is bigger (i.e. 2.1 > 2.1.1 == true, 2 > 2.1 == true).
func (Tag) IsLessThan ¶
IsLessThan tests if a tag is less than another. There are some tag-isms to take into account here, shorter is bigger (i.e. 2.1 < 2.1.1 == false, 2 < 2.1 == false).
func (Tag) IsUpgradeCompatible ¶
IsUpgradeCompatible chekcs if upTag is compatible with a pinned version tag. I.e. pinning to 22-fpm should return true if upTag is 22.2.0-fpm but not 22.2.0-alpine or 23.0.0-fpm
type TagDelta ¶
type TagDelta struct { Major int // major semver difference Minor int // minor semver difference Patch int // patch semver difference }
func ParseDelta ¶
ParseDelta converts a tag difference in the format of X, X.Y or X.Y.Z where X, Y, Z are positive or negative integers or 0
func (TagDelta) UpgradeType ¶
UpgradeType takes exit from UpgradeElemene and returns a numeric representation of upgrade or downgrade 1/-1: patch 2/-2: minor 4/-4: major 0: no change