Skip to content

pkg/operator/image.go: Adjust image path building - #3392

Merged
s-urbaniak merged 4 commits into
prometheus-operator:masterfrom
lilic:fix-image-tag-version
Aug 11, 2020
Merged

s-urbaniak merged 4 commits into
prometheus-operator:masterfrom
lilic:fix-image-tag-version

Conversation

@lilic

@lilic lilic commented Aug 6, 2020

Copy link
Copy Markdown
Contributor

Image can contain tag already, this checks if it does it just returns
the image. Otherwise sha/digest takes priority over tag and lastly
version is taken due to historic reasons.

cc @prometheus-operator/prometheus-operator-reviewers

@brancz

brancz commented Aug 7, 2020 •

Copy link
Copy Markdown
Contributor

Looks like we need to adapt some of the unit test expectations. What this PR does is how I expect image handling to work though, so fixing the unit test expectations is the right thing to do.

@lilic

lilic commented Aug 10, 2020

Copy link
Copy Markdown
Contributor Author

Fixed the unit tests @brancz can you please have another look, thanks!

Comment thread pkg/operator/image.go
if sha != "" {
image = fmt.Sprintf("%s@sha256:%s", baseImage, sha)
_, isTagged := named.(dockerref.Tagged)
_, isDigested := named.(dockerref.Digested)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice 👍

Comment thread pkg/operator/image.go Outdated
image = fmt.Sprintf("%s@sha256:%s", baseImage, sha)
_, isTagged := named.(dockerref.Tagged)
_, isDigested := named.(dockerref.Digested)
if !isTagged && !isDigested {

@s-urbaniak s-urbaniak Aug 10, 2020 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: instead of having a big if block here, return early:

if isTagged || isDigested {
  return image, nil
}

and unindent the complex if-else logic:

  if sha != " { ...
  } else if version != "" {
 ..
  }
return image, nil

this makes the code more linear to read, wdyt?

lilic added 4 commits August 10, 2020 14:49
Image can contain tag already, this checks if it does it just returns
the image. Otherwise sha/digest takes priority over tag and lastly
version is taken due to historic reasons.
@lilic
lilic force-pushed the fix-image-tag-version branch from 40b5cca to 7b4a9d7 Compare August 10, 2020 12:56
@lilic

lilic commented Aug 10, 2020

Copy link
Copy Markdown
Contributor Author

@s-urbaniak addressed your comment, PTAL, thanks!! 🎉

@brancz brancz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@s-urbaniak

Copy link
Copy Markdown
Contributor

lgtm 🎉

@s-urbaniak
s-urbaniak merged commit 54704fa into prometheus-operator:master Aug 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants