Skip to content
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

Correctly parse build tags that contain port numbers #1001

Merged

Conversation

maddisondavid
Copy link
Contributor

Fixes issue #994

When a build tag contains a port number i.e. docker.io:5000/skaffold-helm:my-tag the Helm Strategy was incorrectly performing a basic split and ending up with repository=docker.io,tag=5000/skaffold-helm:my-tag.

This PR fixes the parsing so that the repository is correctly extracted, i.e. repository=docker.io:5000/skaffold-helm,image=my-tag

@codecov-io
Copy link

codecov-io commented Sep 20, 2018

Codecov Report

Merging #1001 into master will decrease coverage by 0.4%.
The diff coverage is 85.71%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1001      +/-   ##
==========================================
- Coverage   40.61%   40.21%   -0.41%     
==========================================
  Files          68       68              
  Lines        2969     3009      +40     
==========================================
+ Hits         1206     1210       +4     
- Misses       1639     1672      +33     
- Partials      124      127       +3
Impacted Files Coverage Δ
pkg/skaffold/docker/reference.go 90% <100%> (+1.76%) ⬆️
pkg/skaffold/deploy/helm.go 63.31% <75%> (-0.83%) ⬇️
pkg/skaffold/deploy/deploy.go 25% <0%> (-75%) ⬇️
pkg/skaffold/runner/runner.go 54.63% <0%> (+0.18%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4fa3512...face328. Read the comment docs.

@@ -135,8 +135,8 @@ func (h *HelmDeployer) deployRelease(ctx context.Context, out io.Writer, r v1alp
for k, v := range params {
setOpts = append(setOpts, "--set")
if r.ImageStrategy.HelmImageConfig.HelmConventionConfig != nil {
tagSplit := strings.Split(v.Tag, ":")
imageRepositoryTag := fmt.Sprintf("%s.repository=%s,%s.tag=%s", k, tagSplit[0], k, tagSplit[1])
tagIndex := strings.LastIndex(v.Tag, ":")
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to parse the image tag with something like docker.ParseReference()? If it works, it would handle all the edge cases better than any string parsing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good, I wasn't aware of docker.ParseReference(), it's annoying that it only gives you the baseName and not also the tag.

Code updated to use docker.ParseReference() which leads to much nicer code.

I followed the style of the helm_test.go to fix up the test, but I'm not super happy about it because the test uses the SAME logic as the code it's testing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Doh, I realise that docker.ParseReference() is in a skaffold package, so probably makes more sense for me to update docker.ParseReference() to include the Tag.

@r2d4 r2d4 added the kokoro:run runs the kokoro jobs on a PR label Sep 20, 2018
@kokoro-team kokoro-team removed the kokoro:run runs the kokoro jobs on a PR label Sep 20, 2018
@maddisondavid
Copy link
Contributor Author

The Travis build is failing but only on the Linux build with some weird missing packages. I'm leaning towards it just being an environmental issue blip during the build but I don't have permission to re-run the build.

@dgageot
Copy link
Contributor

dgageot commented Sep 21, 2018

Let me restart the build

Copy link
Contributor

@dgageot dgageot left a comment

Choose a reason for hiding this comment

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

Thank you @maddisondavid for updating the code.! There's a few nits to be fixed then it can be merged

pkg/skaffold/deploy/helm_test.go Outdated Show resolved Hide resolved
pkg/skaffold/docker/reference_test.go Outdated Show resolved Hide resolved
@dgageot dgageot added the kokoro:run runs the kokoro jobs on a PR label Sep 21, 2018
@kokoro-team kokoro-team removed the kokoro:run runs the kokoro jobs on a PR label Sep 21, 2018
@maddisondavid
Copy link
Contributor Author

I've just run into an issue using MASTER whereby the last letter of the tag is missing when Helm is deployed. Please don't merge this until I can confirm it's not a problem with the code I put in!

@dgageot dgageot added the wip label Sep 21, 2018
@maddisondavid
Copy link
Contributor Author

OK, seems like it must have been something around my environment. Everything appears to be working fine now and deployment is getting and using the correct tag. I just wanted to be sure it wasn't something caused by my code!

@r2d4 r2d4 removed the wip label Sep 24, 2018
@r2d4 r2d4 merged commit dfd7c0d into GoogleContainerTools:master Sep 24, 2018
@r2d4
Copy link
Contributor

r2d4 commented Sep 24, 2018

Thank you @maddisondavid!

@maddisondavid maddisondavid deleted the parse-tags-with-port-numbers branch September 24, 2018 16:39
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.

5 participants