tagcmp/godoc.md

3.7 KiB

tagcmp

import "coopcloud.tech/tagcmp"

Package tagcmp provides image tag comparison operations.

Index

Variables

CommitHashPattern matches commit-like hash tags

var CommitHashPattern = "^[a-f0-9]{7,40}$"

DotPattern matches tags which contain multiple versions

var DotPattern = "([0-9]+)\\.([0-9]+)"

EmptyPattern matches when tags are missing

var EmptyPattern = "^$"

ParametrizedPattern matches when tags are parametrized

var ParametrizedPattern = "\\${.+}"

StringPattern matches when tags are only made up of alphabetic characters

var StringPattern = "^[a-zA-Z]+$"

func IsParsable

func IsParsable(tag string) bool

IsParsable determines if a tag is supported by this library

type ByTag

ByTag sorts tags in asc/desc order where the last element is the latest tag.

type ByTag []Tag

func ByTag Len

func (t ByTag) Len() int

func ByTag Less

func (t ByTag) Less(i, j int) bool

func ByTag Swap

func (t ByTag) Swap(i, j int)

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")
    UsesV        bool   // whether or not the tag uses the "v" prefix
}

func Parse

func Parse(tag string) (Tag, error)

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 Equals

func (t Tag) Equals(tag Tag) bool

Equals tests Tag equality

func Tag IsCompatible

func (t Tag) IsCompatible(tag Tag) bool

IsCompatible determines if two tags can be compared together

func Tag IsGreaterThan

func (t Tag) IsGreaterThan(tag Tag) bool

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

func (t Tag) IsLessThan(tag Tag) bool

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 String

func (t Tag) String() string

String formats a Tag correctly in string representation

Generated by gomarkdoc