Skip to content

Commit

Permalink
Properly tag images with digest when using helm (#2956)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbeaumont authored and dgageot committed Oct 4, 2019
1 parent f7a385e commit d5cfaa8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
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

0 comments on commit d5cfaa8

Please sign in to comment.