diff --git a/pkg/skaffold/deploy/helm.go b/pkg/skaffold/deploy/helm.go index a4b825a8aa3..bce2e824d5c 100644 --- a/pkg/skaffold/deploy/helm.go +++ b/pkg/skaffold/deploy/helm.go @@ -401,18 +401,23 @@ func (h *HelmDeployer) deleteRelease(ctx context.Context, out io.Writer, r lates func (h *HelmDeployer) joinTagsToBuildResult(builds []build.Artifact, params map[string]string) (map[string]build.Artifact, error) { imageToBuildResult := map[string]build.Artifact{} - for _, build := range builds { - imageToBuildResult[build.ImageName] = build + for _, b := range builds { + imageToBuildResult[b.ImageName] = b } paramToBuildResult := map[string]build.Artifact{} for param, imageName := range params { newImageName := util.SubstituteDefaultRepoIntoImage(h.defaultRepo, imageName) - build, ok := imageToBuildResult[newImageName] + b, ok := imageToBuildResult[newImageName] if !ok { - return nil, fmt.Errorf("no build present for %s", imageName) + if len(builds) == 0 { + logrus.Debugf("no build artifacts present. Assuming skaffold deploy. Continuing with %s", imageName) + b = build.Artifact{ImageName: imageName, Tag: imageName} + } else { + return nil, fmt.Errorf("no build present for %s", imageName) + } } - paramToBuildResult[param] = build + paramToBuildResult[param] = b } return paramToBuildResult, nil } diff --git a/pkg/skaffold/deploy/helm_test.go b/pkg/skaffold/deploy/helm_test.go index 37c36d1bf5f..b5cf380ece0 100644 --- a/pkg/skaffold/deploy/helm_test.go +++ b/pkg/skaffold/deploy/helm_test.go @@ -212,7 +212,7 @@ spec: containers: - name: skaffold-helm image: gcr.io/nick-cloudbuild/skaffold-helm:f759510436c8fd6f7ffa13dd9e9d85e64bec8d2bfd12c5aa3fb9af1288eccdab - imagePullPolicy: + imagePullPolicy: command: ["/bin/bash", "-c", "--" ] args: ["while true; do sleep 30; done;"] resources: @@ -301,7 +301,13 @@ func TestHelmDeploy(t *testing.T) { builds: testBuilds, }, { - description: "deploy error unmatched parameter", + description: "deploy should not error for unmatched parameter when no builds present", + cmd: &MockHelm{t: t}, + runContext: makeRunContext(testDeployConfigParameterUnmatched, false), + builds: nil, + }, + { + description: "deploy should error for unmatched parameter when builds present", cmd: &MockHelm{t: t}, runContext: makeRunContext(testDeployConfigParameterUnmatched, false), builds: testBuilds,