tagcmp/godoc.md

235 lines
5.7 KiB
Markdown
Raw Permalink Normal View History

2021-08-08 17:05:39 +00:00
<!-- Code generated by gomarkdoc. DO NOT EDIT -->
# tagcmp
```go
import "coopcloud.tech/tagcmp"
```
Package tagcmp provides image tag comparison operations\.
## Index
- [Variables](<#variables>)
- [func IsParsable(tag string) bool](<#func-isparsable>)
- [type ByTagAsc](<#type-bytagasc>)
- [func (t ByTagAsc) Len() int](<#func-bytagasc-len>)
- [func (t ByTagAsc) Less(i, j int) bool](<#func-bytagasc-less>)
- [func (t ByTagAsc) Swap(i, j int)](<#func-bytagasc-swap>)
- [type ByTagDesc](<#type-bytagdesc>)
- [func (t ByTagDesc) Len() int](<#func-bytagdesc-len>)
- [func (t ByTagDesc) Less(i, j int) bool](<#func-bytagdesc-less>)
- [func (t ByTagDesc) Swap(i, j int)](<#func-bytagdesc-swap>)
2021-08-08 17:05:39 +00:00
- [type Tag](<#type-tag>)
- [func Parse(tag string) (Tag, error)](<#func-parse>)
- [func (t Tag) Equals(tag Tag) bool](<#func-tag-equals>)
- [func (t Tag) IsCompatible(tag Tag) bool](<#func-tag-iscompatible>)
- [func (t Tag) IsGreaterThan(tag Tag) bool](<#func-tag-isgreaterthan>)
- [func (t Tag) IsLessThan(tag Tag) bool](<#func-tag-islessthan>)
- [func (t Tag) String() string](<#func-tag-string>)
2021-10-11 22:07:50 +00:00
- [func (curTag Tag) UpgradeDelta(newTag Tag) (TagDelta, error)](<#func-tag-upgradedelta>)
- [type TagDelta](<#type-tagdelta>)
- [func ParseDelta(delta string) (TagDelta, error)](<#func-parsedelta>)
- [func (t TagDelta) String() string](<#func-tagdelta-string>)
- [func (d TagDelta) UpgradeType() int](<#func-tagdelta-upgradetype>)
2021-08-08 17:05:39 +00:00
## Variables
CommitHashPattern matches commit\-like hash tags
```go
var CommitHashPattern = "^[a-f0-9]{7,40}$"
```
DotPattern matches tags which contain multiple versions
```go
var DotPattern = "([0-9]+)\\.([0-9]+)"
```
EmptyPattern matches when tags are missing
```go
var EmptyPattern = "^$"
```
ParametrizedPattern matches when tags are parametrized
```go
var ParametrizedPattern = "\\${.+}"
```
StringPattern matches when tags are only made up of alphabetic characters
```go
var StringPattern = "^[a-zA-Z]+$"
```
## func IsParsable
2021-08-08 17:05:39 +00:00
```go
func IsParsable(tag string) bool
2021-08-08 17:05:39 +00:00
```
IsParsable determines if a tag is supported by this library
2021-08-08 17:05:39 +00:00
## type ByTagAsc
2021-08-08 17:05:39 +00:00
ByTagAsc sorts tags in ascending order where the last element is the latest tag\.
2021-08-08 17:05:39 +00:00
```go
type ByTagAsc []Tag
2021-08-08 17:05:39 +00:00
```
### func \(ByTagAsc\) Len
2021-08-08 17:05:39 +00:00
```go
func (t ByTagAsc) Len() int
2021-08-08 17:05:39 +00:00
```
### func \(ByTagAsc\) Less
2021-08-08 17:05:39 +00:00
```go
func (t ByTagAsc) Less(i, j int) bool
2021-08-08 17:05:39 +00:00
```
### func \(ByTagAsc\) Swap
2021-08-08 17:05:39 +00:00
```go
func (t ByTagAsc) Swap(i, j int)
```
## type ByTagDesc
ByTagDesc sorts tags in descending order where the first element is the latest tag\.
```go
type ByTagDesc []Tag
```
### func \(ByTagDesc\) Len
```go
func (t ByTagDesc) Len() int
```
### func \(ByTagDesc\) Less
```go
func (t ByTagDesc) Less(i, j int) bool
```
### func \(ByTagDesc\) Swap
```go
func (t ByTagDesc) Swap(i, j int)
2021-08-08 17:05:39 +00:00
```
## type Tag
```go
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
2021-10-11 22:07:50 +00:00
Suffix string // tag suffix (e.g. "-alpine") [would be release candidate in semver]
2021-08-08 17:05:39 +00:00
UsesV bool // whether or not the tag uses the "v" prefix
2021-10-11 22:07:50 +00:00
Metadata string // metadata: what's after + and after the first "-"
2021-08-08 17:05:39 +00:00
}
```
### func Parse
```go
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
```go
func (t Tag) Equals(tag Tag) bool
```
Equals tests Tag equality
### func \(Tag\) IsCompatible
```go
func (t Tag) IsCompatible(tag Tag) bool
```
IsCompatible determines if two tags can be compared together
### func \(Tag\) IsGreaterThan
```go
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
```go
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
```go
func (t Tag) String() string
```
String formats a Tag correctly in string representation
2021-10-11 22:07:50 +00:00
### func \(Tag\) UpgradeDelta
```go
func (curTag Tag) UpgradeDelta(newTag Tag) (TagDelta, error)
```
UpgradeDelta returns a TagDelta object which is the difference between an old and new tag It can contain negative numbers if comparing with an older tag\.
## type TagDelta
```go
type TagDelta struct {
Major int // major semver difference
Minor int // minor semver difference
Patch int // patch semver difference
}
```
### func ParseDelta
2021-10-02 21:16:32 +00:00
```go
2021-10-11 22:07:50 +00:00
func ParseDelta(delta string) (TagDelta, error)
2021-10-02 21:16:32 +00:00
```
2021-10-11 22:07:50 +00:00
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\) String
```go
func (t TagDelta) String() string
```
### func \(TagDelta\) UpgradeType
```go
func (d TagDelta) UpgradeType() int
```
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
2021-10-02 21:16:32 +00:00
2021-08-08 17:05:39 +00:00
Generated by [gomarkdoc](<https://github.com/princjef/gomarkdoc>)