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

Issue #836: Use releaseName to get release info. #855

Merged
merged 1 commit into from Jul 26, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/skaffold/deploy/helm.go
Expand Up @@ -236,7 +236,7 @@ func (h *HelmDeployer) deployRelease(out io.Writer, r v1alpha2.HelmRelease, buil
args = append(args, setOpts...)

helmErr := h.helm(out, args...)
return h.getDeployResults(ns, r.Name), helmErr
return h.getDeployResults(ns, releaseName), helmErr
}

// imageName if the given string includes a fully qualified docker image name then lets trim just the tag part out
Expand Down
31 changes: 31 additions & 0 deletions pkg/skaffold/deploy/helm_test.go
Expand Up @@ -24,6 +24,7 @@ import (
"io/ioutil"
"os"
"os/exec"
"strings"
"testing"

"github.com/GoogleContainerTools/skaffold/pkg/skaffold/build"
Expand Down Expand Up @@ -93,6 +94,24 @@ var testDeployFooWithPackaged = &v1alpha2.HelmDeploy{
},
}

var testDeployWithTemplatedName = &v1alpha2.HelmDeploy{
Releases: []v1alpha2.HelmRelease{
{
Name: "{{.USER}}-skaffold-helm",
ChartPath: "examples/test",
Values: map[string]string{
"image.tag": "skaffold-helm",
},
Overrides: map[string]interface{}{
"foo": "bar",
},
SetValues: map[string]string{
"some.key": "somevalue",
},
},
},
}

var testNamespace = "testNamespace"

var validDeployYaml = `
Expand Down Expand Up @@ -267,6 +286,12 @@ func TestHelmDeploy(t *testing.T) {
),
builds: testBuildsFoo,
},
{
description: "deploy and get templated release name",
cmd: &MockHelm{t: t},
deployer: NewHelmDeployer(testDeployWithTemplatedName, testKubeContext, testNamespace),
builds: testBuilds,
},
}

for _, tt := range tests {
Expand Down Expand Up @@ -306,6 +331,12 @@ func (m *MockHelm) RunCmd(c *exec.Cmd) error {
m.t.Errorf("Invalid kubernetes context %v", c)
}

if c.Args[3] == "get" || c.Args[3] == "upgrade" {
if releaseName := c.Args[4]; strings.Contains(releaseName, "{{") {
m.t.Errorf("Invalid release name: %v", releaseName)
}
}

switch c.Args[3] {
case "get":
return m.getResult
Expand Down