Merge pull request #1363 from adamreese/feat/helm-init-canary

feat(helm): add canary option to init command
pull/1142/head
Adam Reese 8 years ago committed by GitHub
commit 1a7373e584

@ -46,6 +46,7 @@ const (
type initCmd struct { type initCmd struct {
image string image string
clientOnly bool clientOnly bool
canary bool
out io.Writer out io.Writer
home helmpath.Home home helmpath.Home
kubeClient unversioned.DeploymentsNamespacer kubeClient unversioned.DeploymentsNamespacer
@ -68,7 +69,8 @@ func newInitCmd(out io.Writer) *cobra.Command {
}, },
} }
cmd.Flags().StringVarP(&i.image, "tiller-image", "i", "", "override tiller image") cmd.Flags().StringVarP(&i.image, "tiller-image", "i", "", "override tiller image")
cmd.Flags().BoolVarP(&i.clientOnly, "client-only", "c", false, "If set does not install tiller") cmd.Flags().BoolVar(&i.canary, "canary-image", false, "use the canary tiller image")
cmd.Flags().BoolVarP(&i.clientOnly, "client-only", "c", false, "if set does not install tiller")
return cmd return cmd
} }
@ -86,7 +88,7 @@ func (i *initCmd) run() error {
} }
i.kubeClient = c i.kubeClient = c
} }
if err := installer.Install(i.kubeClient, tillerNamespace, i.image, flagDebug); err != nil { if err := installer.Install(i.kubeClient, tillerNamespace, i.image, i.canary, flagDebug); err != nil {
if !kerrors.IsAlreadyExists(err) { if !kerrors.IsAlreadyExists(err) {
return fmt.Errorf("error installing: %s", err) return fmt.Errorf("error installing: %s", err)
} }

@ -35,8 +35,11 @@ const defaultImage = "gcr.io/kubernetes-helm/tiller"
// command failed. // command failed.
// //
// If verbose is true, this will print the manifest to stdout. // If verbose is true, this will print the manifest to stdout.
func Install(client unversioned.DeploymentsNamespacer, namespace, image string, verbose bool) error { func Install(client unversioned.DeploymentsNamespacer, namespace, image string, canary, verbose bool) error {
if image == "" { switch {
case canary:
image = defaultImage + ":canary"
case image == "":
image = fmt.Sprintf("%s:%s", defaultImage, version.Version) image = fmt.Sprintf("%s:%s", defaultImage, version.Version)
} }
obj := generateDeployment(image) obj := generateDeployment(image)

@ -42,7 +42,24 @@ func TestInstall(t *testing.T) {
return true, obj, nil return true, obj, nil
}) })
err := Install(fake.Extensions(), "default", image, false) err := Install(fake.Extensions(), "default", image, false, false)
if err != nil {
t.Errorf("unexpected error: %#+v", err)
}
}
func TestInstall_canary(t *testing.T) {
fake := testclient.Fake{}
fake.AddReactor("create", "deployments", func(action testclient.Action) (bool, runtime.Object, error) {
obj := action.(testclient.CreateAction).GetObject().(*extensions.Deployment)
i := obj.Spec.Template.Spec.Containers[0].Image
if i != "gcr.io/kubernetes-helm/tiller:canary" {
t.Errorf("expected canary image, got '%s'", i)
}
return true, obj, nil
})
err := Install(fake.Extensions(), "default", "", true, false)
if err != nil { if err != nil {
t.Errorf("unexpected error: %#+v", err) t.Errorf("unexpected error: %#+v", err)
} }

Loading…
Cancel
Save