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

Remove build dep for helm deploy #2121

Merged
merged 4 commits into from
May 20, 2019
Merged
Show file tree
Hide file tree
Changes from 3 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
15 changes: 10 additions & 5 deletions pkg/skaffold/deploy/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.Warnf("no build artifacts present. Assuming skaffold deploy. Continuing with %s", imageName)
Copy link
Contributor

Choose a reason for hiding this comment

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

I would make this a Debug statement instead.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would actually just remove this altogether.

if len(builds) > 0 {
  return nil, fmt.Errorf("no build present for %s", imageName)
}
b = build.Artifact{ImageName: imageName, Tag: imageName}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nkubala I wanted to print a warn or a debug message to just give users more insight in to what is happening.

Copy link
Contributor

Choose a reason for hiding this comment

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

right, this would do that. I'm just proposing that you remove the log message since I don't really think it's necessary. the change I proposed is logically equivalent, just a bit easier to read IMO.

if we didn't find the build in the build map:
  * if build map is not empty -> error out because we couldn't find the specified artifact
  * continue, because we want to allow deploying without anything being built

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
}
Expand Down
10 changes: 8 additions & 2 deletions pkg/skaffold/deploy/helm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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,
Expand Down