New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix issue with force-update and semver #192
Conversation
Codecov Report
@@ Coverage Diff @@
## master #192 +/- ##
==========================================
+ Coverage 66.77% 66.99% +0.22%
==========================================
Files 20 20
Lines 1502 1503 +1
==========================================
+ Hits 1003 1007 +4
+ Misses 406 405 -1
+ Partials 93 91 -2
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @iamnoah - thanks for this bug fix, and also for including a unit test for it!
I think we can simplify the fix, please see below. WDYT?
pkg/argocd/argocd.go
Outdated
// code consuming this list assumes the tag is valid, but for a force update, we may only have a constraint which isn't a valid tag | ||
// if using semver, try to parse the tag and remove it if it fails | ||
if strategy, set := annotations[fmt.Sprintf(common.UpdateStrategyAnnotation, img.ImageAlias)]; (!set || | ||
image.ParseUpdateStrategy(strategy) == image.VersionSortSemVer) && img.ImageTag != nil { | ||
_, err := semver.NewVersion(img.ImageTag.TagName) | ||
if err != nil { | ||
log.Debugf("Dropping tag from force-update of image %s because %v", img, err) | ||
img.ImageTag = &tag.ImageTag{} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we can simply set the tag to nil
from what is specified in image-list
, without having to perform checks for the update strategy or whether the tag can be correctly parsed as a semver.
If an image tag is nil
in one of the images we check for, we explicitly create an empty tag here and handle that case appropriately here
So I think we can safely remove all the logic here, and just set img.ImageTag = nil
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense! I'll update shortly
Regarding the failing golangci-lint check, it will check for properly formatted import blocks. The logic it follows is to check
Import groups are Golang standard library, own package, and external packages, so basically:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you @iamnoah !
I realize the test might be a little strange, but I assumed my issue had something to do with customize being used to change the image name so I started there and finally narrowed it down to the version constraint being used as a version.