Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #855 from johnmshields/master
Issue #836: Use releaseName to get release info.
  • Loading branch information
dgageot committed Jul 26, 2018
2 parents 62f1d0b + 26b4cfc commit e85d362
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
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

0 comments on commit e85d362

Please sign in to comment.