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

Properly tag images with digest when using helm #2956

Merged
merged 1 commit into from
Oct 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions pkg/skaffold/deploy/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,13 @@ func getImageSetValueFromHelmStrategy(cfg *latest.HelmConventionConfig, valueNam
return "", errors.Wrapf(err, "cannot parse the image reference %s", tag)
}

var imageTag string
if dockerRef.Digest != "" {
imageTag = fmt.Sprintf("%s@%s", dockerRef.Tag, dockerRef.Digest)
} else {
imageTag = dockerRef.Tag
}

if cfg.ExplicitRegistry {
if dockerRef.Domain == "" {
return "", errors.New(fmt.Sprintf("image reference %s has no domain", tag))
Expand All @@ -420,13 +427,13 @@ func getImageSetValueFromHelmStrategy(cfg *latest.HelmConventionConfig, valueNam
valueName,
dockerRef.Domain,
dockerRef.Path,
dockerRef.Tag,
imageTag,
), nil
}
return fmt.Sprintf(
"%[1]s.repository=%[2]s,%[1]s.tag=%[3]s",
valueName, dockerRef.BaseName,
dockerRef.Tag,
imageTag,
), nil
}
return fmt.Sprintf("%s=%s", valueName, tag), nil
Expand Down
8 changes: 8 additions & 0 deletions pkg/skaffold/deploy/helm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,14 @@ func TestGetImageSetValueFromHelmStrategy(t *testing.T) {
},
shouldErr: true,
},
{
description: "Helm set values using digest",
valueName: "image",
tag: "skaffold-helm:stable@sha256:45b23dee08af5e43a7fea6c4cf9c25ccf269ee113168c19722f87876677c5cb2",
expected: "image.repository=skaffold-helm,image.tag=stable@sha256:45b23dee08af5e43a7fea6c4cf9c25ccf269ee113168c19722f87876677c5cb2",
strategy: &latest.HelmConventionConfig{},
shouldErr: false,
},
}
for _, test := range tests {
testutil.Run(t, test.description, func(t *testutil.T) {
Expand Down