fix: handle tags without images gracefully
continuous-integration/drone/push Build is passing Details

This commit is contained in:
decentral1se 2022-01-05 17:32:58 +01:00
parent 74dfb12fd6
commit 1b37d2d5f5
Signed by: decentral1se
GPG Key ID: 03789458B3D0C410
1 changed files with 12 additions and 12 deletions

View File

@ -115,20 +115,20 @@ You may invoke this command in "wizard" mode and be prompted for input:
} }
logrus.Debugf("retrieved %s from remote registry for %s", regVersions, image) logrus.Debugf("retrieved %s from remote registry for %s", regVersions, image)
if strings.Contains(image, "library") { image = recipePkg.StripTagMeta(image)
// ParseNormalizedNamed prepends 'library' to images like nginx:<tag>,
// postgres:<tag>, i.e. images which do not have a username in the switch img.(type) {
// first position of the string case reference.NamedTagged:
image = strings.Split(image, "/")[1] if !tagcmp.IsParsable(img.(reference.NamedTagged).Tag()) {
} logrus.Debugf("%s not considered semver-like", img.(reference.NamedTagged).Tag())
semverLikeTag := true }
if !tagcmp.IsParsable(img.(reference.NamedTagged).Tag()) { default:
logrus.Debugf("%s not considered semver-like", img.(reference.NamedTagged).Tag()) logrus.Warnf("unable to read tag for image %s, is it missing? skipping upgrade for %s", image, service.Name)
semverLikeTag = false continue
} }
tag, err := tagcmp.Parse(img.(reference.NamedTagged).Tag()) tag, err := tagcmp.Parse(img.(reference.NamedTagged).Tag())
if err != nil && semverLikeTag { if err != nil {
logrus.Fatal(err) logrus.Fatal(err)
} }
logrus.Debugf("parsed %s for %s", tag, service.Name) logrus.Debugf("parsed %s for %s", tag, service.Name)
@ -148,7 +148,7 @@ You may invoke this command in "wizard" mode and be prompted for input:
sort.Sort(tagcmp.ByTagDesc(compatible)) sort.Sort(tagcmp.ByTagDesc(compatible))
if len(compatible) == 0 && semverLikeTag { if len(compatible) == 0 {
logrus.Info(fmt.Sprintf("no new versions available for %s, %s is the latest", image, tag)) logrus.Info(fmt.Sprintf("no new versions available for %s, %s is the latest", image, tag))
continue // skip on to the next tag and don't update any compose files continue // skip on to the next tag and don't update any compose files
} }