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

fix: resolve issue where skaffold would not add digest when using helm in v1 -> v2 migration case #8269

Merged
merged 1 commit into from
Dec 21, 2022
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
2 changes: 1 addition & 1 deletion integration/helm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestHelmDeploy(t *testing.T) {
skaffold.Delete().InDir("testdata/helm").InNs(ns.Name).WithEnv(env).RunOrFail(t)
}

func TestDevHelmMultiConfig(t *testing.T) {
func TestRunHelmMultiConfig(t *testing.T) {
var tests = []struct {
description string
dir string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ manifests:
createNamespace: true
name: app1
setValueTemplates:
image.repository: '{{.IMAGE_REPO_app1}}'
image.tag: "{{.IMAGE_TAG_app1}}"
image.repository: "{{.IMAGE_REPO_app1}}"
image.tag: "{{.IMAGE_TAG_app1}}@{{.IMAGE_DIGEST_app1}}"
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ manifests:
createNamespace: true
name: app2
setValueTemplates:
image.repository: '{{.IMAGE_REPO_app2}}'
image.tag: "{{.IMAGE_TAG_app2}}"
image.repository: "{{.IMAGE_REPO_app2}}"
image.tag: "{{.IMAGE_TAG_app2}}@{{.IMAGE_DIGEST_app2}}"
6 changes: 6 additions & 0 deletions pkg/skaffold/helm/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ func ConstructOverrideArgs(r *latest.HelmRelease, builds []graph.Artifact, args
return nil, err
}

// hack required when using new Skaffold v2.X.Y setValueTemplates w/ Skaffold v1.X.Y "imageStrategy: helm"
// ex: image: "{{.Values.image.repository}}:{{.Values.image.tag}}"
// when the helm template replacements are done with `dev` and `run` there
// is an additional `@` suffix inserted that needs to be removed or else deploys will fail
v = strings.TrimSuffix(v, "@")

args = append(args, "--set", fmt.Sprintf("%s=%s", expandedKey, v))
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/skaffold/schema/v2beta29/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func upgradeOnePipeline(oldPipeline, newPipeline interface{}) error {
if svts == nil {
svts = map[string]string{}
}
svts[k+".tag"] = fmt.Sprintf("{{.IMAGE_TAG_%s}}", validV)
svts[k+".tag"] = fmt.Sprintf("{{.IMAGE_TAG_%s}}@{{.IMAGE_DIGEST_%s}}", validV, validV)
svts[k+".repository"] = fmt.Sprintf("{{.IMAGE_REPO_%s}}", validV)
if oldPL.Deploy.HelmDeploy.Releases[i].ImageStrategy.HelmConventionConfig.ExplicitRegistry {
// is 'helm' imageStrategy + explicitRegistry
Expand Down