Skip to content
This repository was archived by the owner on Mar 27, 2024. It is now read-only.

only append latest tag to image once #202

Merged
merged 3 commits into from
Mar 14, 2018

Conversation

nkubala
Copy link
Contributor

@nkubala nkubala commented Mar 14, 2018

Also, use regex to check if image has tag. Previously, we were just doing a simple strings.Contains(image, ":"), which would give us a false positive when checking strings with the remote:// or daemon:// prefixes. This should fix those cases.


// checks to see if an image string contains a tag.
func HasTag(image string) bool {
tagRegex := regexp.MustCompile(".*:[^/]*$")
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you add some unit tests for the regex?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

tejal29
tejal29 previously approved these changes Mar 14, 2018
Copy link

@tejal29 tejal29 left a comment

Choose a reason for hiding this comment

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

LGTM except 1 nit

cmd/root.go Outdated
@@ -135,28 +135,21 @@ func getPrepperForImage(image string) (pkgutil.Prepper, error) {
}

// see if the image name has tag provided, if not add latest as tag
if !strings.Contains(image, ":") {
if !pkgutil.HasTag(image) {
image = image + ":latest"
Copy link

Choose a reason for hiding this comment

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

Create a Default for this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants