added warning and set default image for unreleased versions of helm

pull/3781/head
Ryan Hartje 8 years ago
parent 94a5f3a1eb
commit 2c390a845e

@ -23,6 +23,7 @@ import (
"fmt" "fmt"
"io" "io"
"os" "os"
"strings"
"time" "time"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -36,6 +37,7 @@ import (
"k8s.io/helm/pkg/helm/helmpath" "k8s.io/helm/pkg/helm/helmpath"
"k8s.io/helm/pkg/helm/portforwarder" "k8s.io/helm/pkg/helm/portforwarder"
"k8s.io/helm/pkg/repo" "k8s.io/helm/pkg/repo"
"k8s.io/helm/pkg/version"
) )
const initDesc = ` const initDesc = `
@ -323,6 +325,13 @@ func (i *initCmd) run() error {
fmt.Fprintln(i.out, "Not installing Tiller due to 'client-only' flag having been set") fmt.Fprintln(i.out, "Not installing Tiller due to 'client-only' flag having been set")
} }
if !(len(strings.Split(version.Version, ".")) > 2) && !i.opts.UseCanary && len(i.opts.ImageSpec) == 0 {
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!") fmt.Fprintln(i.out, "Happy Helming!")
return nil return nil
} }

@ -20,6 +20,7 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"reflect" "reflect"
"strings"
"testing" "testing"
"github.com/ghodss/yaml" "github.com/ghodss/yaml"
@ -57,6 +58,10 @@ func TestDeploymentManifest(t *testing.T) {
t.Fatalf("%s: error %q", tt.name, err) 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" && !(len(strings.Split(version.Version, ".")) > 2) {
tt.expect = "gcr.io/kubernetes-helm/tiller:canary"
}
if got := dep.Spec.Template.Spec.Containers[0].Image; got != tt.expect { 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) t.Errorf("%s: expected image %q, got %q", tt.name, tt.expect, got)
} }

@ -18,6 +18,7 @@ package installer // import "k8s.io/helm/cmd/helm/installer"
import ( import (
"fmt" "fmt"
"strings"
"k8s.io/api/core/v1" "k8s.io/api/core/v1"
"k8s.io/helm/pkg/strvals" "k8s.io/helm/pkg/strvals"
@ -101,6 +102,9 @@ func (opts *Options) selectImage() string {
case opts.UseCanary: case opts.UseCanary:
return defaultImage + ":canary" return defaultImage + ":canary"
case opts.ImageSpec == "": case opts.ImageSpec == "":
if !(len(strings.Split(version.Version, ".")) > 2) {
return defaultImage + ":canary"
}
return fmt.Sprintf("%s:%s", defaultImage, version.Version) return fmt.Sprintf("%s:%s", defaultImage, version.Version)
default: default:
return opts.ImageSpec return opts.ImageSpec

Loading…
Cancel
Save