added warning and set default image for unreleased versions of helm for #3770 (#3781)

* added warning and set default image for unreleased versions of helm

* changed to BuildMetadata

* changed to BuildMetadata

* added check for clientOnly flag
pull/5252/head
Ryan Hartje 6 years ago committed by Matthew Fisher
parent 7a70459ca1
commit c9dfd25071

@ -36,6 +36,7 @@ import (
"k8s.io/helm/pkg/helm/helmpath"
"k8s.io/helm/pkg/helm/portforwarder"
"k8s.io/helm/pkg/repo"
"k8s.io/helm/pkg/version"
)
const initDesc = `
@ -315,6 +316,14 @@ func (i *initCmd) run() error {
fmt.Fprintln(i.out, "Not installing Tiller due to 'client-only' flag having been set")
}
needsDefaultImage := !i.clientOnly && !i.opts.UseCanary && len(i.opts.ImageSpec) == 0 && version.BuildMetadata == "unreleased"
if needsDefaultImage {
fmt.Fprintf(i.out, "\nWarning: You appear to be using an unreleased version of Helm. Please either use the\n"+
"--canary-image flag, or specify your desired tiller version with --tiller-image.\n\n"+
"Ex:\n"+
"$ helm init --tiller-image gcr.io/kubernetes-helm/tiller:v2.8.2\n\n")
}
fmt.Fprintln(i.out, "Happy Helming!")
return nil
}

@ -53,6 +53,10 @@ func TestDeployment(t *testing.T) {
t.Fatalf("%s: error %q", tt.name, err)
}
// Unreleased versions of helm don't have a release image. See issue 3370
if tt.name == "default" && version.BuildMetadata == "unreleased" {
tt.expect = "gcr.io/kubernetes-helm/tiller:canary"
}
if got := dep.Spec.Template.Spec.Containers[0].Image; got != tt.expect {
t.Errorf("%s: expected image %q, got %q", tt.name, tt.expect, got)
}

@ -105,6 +105,9 @@ func (opts *Options) SelectImage() string {
case opts.UseCanary:
return defaultImage + ":canary"
case opts.ImageSpec == "":
if version.BuildMetadata == "unreleased" {
return defaultImage + ":canary"
}
return fmt.Sprintf("%s:%s", defaultImage, version.Version)
default:
return opts.ImageSpec

Loading…
Cancel
Save