feat: add pin compatibility check

This commit is contained in:
knoflook 2021-11-01 10:48:22 +01:00
parent 3cac15cba2
commit 7586abc3ca
Signed by: knoflook
GPG Key ID: D6A1D0E8FC4FEF1C
2 changed files with 25 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
fmtcoverage.html

View File

@ -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) {