Commit 2b33bf6b authored by Robert James Hernandez's avatar Robert James Hernandez Committed by Matthew Fisher

Fix for checking helm version slice bounds out of range (#4609)

* fix(helm): Use env to locate bash

Leverage '/usr/bin/env bash` for find bash instead of hardcoding
'/bin/bash' since some *nix OSes have it installed elsewhere.
Signed-off-by: 's avatarRobert James Hernandez <rob@sarcasticadmin.com>

* test(helm): Adding case for versions short flag

When git sha is empty if being built from tarball running 'helm version
--short' should just ignore '--short' since sha is empty. Adding test
to ensure this is the case.
Signed-off-by: 's avatarRobert James Hernandez <rob@sarcasticadmin.com>

* fix(helm): ignore short flag when sha is empty
Signed-off-by: 's avatarRobert James Hernandez <rob@sarcasticadmin.com>
parent ba260dca
......@@ -18,7 +18,7 @@ BINDIR := $(CURDIR)/bin
BINARIES := helm tiller
# Required for globs to work correctly
SHELL=/bin/bash
SHELL=/usr/bin/env bash
.PHONY: all
all: build
......
......@@ -145,7 +145,7 @@ func getK8sVersion() (*apiVersion.Info, error) {
}
func formatVersion(v *pb.Version, short bool) string {
if short {
if short && v.GitCommit != "" {
return fmt.Sprintf("%s+g%s", v.SemVer, v.GitCommit[:7])
}
return fmt.Sprintf("%#v", v)
......
......@@ -57,6 +57,12 @@ func TestVersion(t *testing.T) {
flags: []string{"--template", "{{ .Client.SemVer }} {{ .Server.SemVer }}"},
expected: lver + " " + sver,
},
{
name: "client short empty git",
args: []string{},
flags: []string{"-c", "--short"},
expected: lver,
},
}
settings.TillerHost = "fake-localhost"
runReleaseCases(t, tests, func(c *helm.FakeClient, out io.Writer) *cobra.Command {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment