fix: don't crash when there is a more serious upgrade available

This commit is contained in:
knoflook 2021-10-05 11:39:05 +02:00 committed by Gitea
parent 49f90674f2
commit 11c4651a3b

View File

@ -130,6 +130,10 @@ is up to the end-user to decide.
break break
} }
} }
if upgradeTag == "" {
logrus.Warnf("not upgrading from '%s' to '%s' for '%s', because the upgrade type is more serious than what user wants.", tag.String(), compatible[0].String(), image)
continue
}
} else { } else {
msg := fmt.Sprintf("upgrade to which tag? (service: %s, tag: %s)", service.Name, tag) msg := fmt.Sprintf("upgrade to which tag? (service: %s, tag: %s)", service.Name, tag)
if !tagcmp.IsParsable(img.(reference.NamedTagged).Tag()) { if !tagcmp.IsParsable(img.(reference.NamedTagged).Tag()) {
@ -154,7 +158,7 @@ is up to the end-user to decide.
if err := recipe.UpdateTag(image, upgradeTag); err != nil { if err := recipe.UpdateTag(image, upgradeTag); err != nil {
logrus.Fatal(err) logrus.Fatal(err)
} }
logrus.Infof("tag updated from '%s' to '%s' for '%s'", tag.String(), upgradeTag, recipe.Name) logrus.Infof("tag upgraded from '%s' to '%s' for '%s'", tag.String(), upgradeTag, image)
} }
return nil return nil