forked from coop-cloud/tagcmp
feat: add pin compatibility check
This commit is contained in:
parent
3cac15cba2
commit
7586abc3ca
|
@ -0,0 +1 @@
|
|||
fmtcoverage.html
|
24
tagcmp.go
24
tagcmp.go
|
@ -187,6 +187,30 @@ func (t Tag) IsCompatible(tag Tag) bool {
|
|||
return true
|
||||
}
|
||||
|
||||
// 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
|
||||
func (pin Tag) IsUpgradeCompatible(upTag Tag) bool {
|
||||
if pin.Suffix != upTag.Suffix {
|
||||
return false
|
||||
}
|
||||
if pin.Major != upTag.Major {
|
||||
return false
|
||||
}
|
||||
if pin.MissingMinor {
|
||||
return true
|
||||
}
|
||||
if pin.Minor != upTag.Minor {
|
||||
return false
|
||||
}
|
||||
if pin.MissingPatch {
|
||||
return true
|
||||
}
|
||||
if pin.Patch != upTag.Patch {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// 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.
|
||||
func (curTag Tag) UpgradeDelta(newTag Tag) (TagDelta, error) {
|
||||
|
|
Loading…
Reference in New Issue