Merge pull request #1014 from technosophos/fix/1010-reuse-name-replace

fix(helm): rename --reuse-name to --replace
pull/1017/head
Matt Butcher 9 years ago committed by GitHub
commit 603bb20ed4

@ -59,7 +59,7 @@ type installCmd struct {
chartPath string chartPath string
dryRun bool dryRun bool
disableHooks bool disableHooks bool
reuseName bool replace bool
out io.Writer out io.Writer
client helm.Interface client helm.Interface
values *values values *values
@ -98,7 +98,7 @@ func newInstallCmd(c helm.Interface, out io.Writer) *cobra.Command {
f.StringVar(&inst.namespace, "namespace", "default", "the namespace to install the release into") f.StringVar(&inst.namespace, "namespace", "default", "the namespace to install the release into")
f.BoolVar(&inst.dryRun, "dry-run", false, "simulate an install") f.BoolVar(&inst.dryRun, "dry-run", false, "simulate an install")
f.BoolVar(&inst.disableHooks, "no-hooks", false, "prevent hooks from running during install") f.BoolVar(&inst.disableHooks, "no-hooks", false, "prevent hooks from running during install")
f.BoolVar(&inst.reuseName, "reuse-name", false, "force Tiller to re-use the given name, even if that name is already used. This is unsafe in production") f.BoolVar(&inst.replace, "replace", false, "re-use the given name, even if that name is already used. This is unsafe in production")
f.Var(inst.values, "set", "set values on the command line. Separate values with commas: key1=val1,key2=val2") f.Var(inst.values, "set", "set values on the command line. Separate values with commas: key1=val1,key2=val2")
return cmd return cmd
} }
@ -119,7 +119,7 @@ func (i *installCmd) run() error {
helm.ValueOverrides(rawVals), helm.ValueOverrides(rawVals),
helm.ReleaseName(i.name), helm.ReleaseName(i.name),
helm.InstallDryRun(i.dryRun), helm.InstallDryRun(i.dryRun),
helm.InstallReuseName(i.reuseName), helm.InstallReuseName(i.replace),
helm.InstallDisableHooks(i.disableHooks)) helm.InstallDisableHooks(i.disableHooks))
if err != nil { if err != nil {
return prettyError(err) return prettyError(err)

@ -59,9 +59,9 @@ func TestInstall(t *testing.T) {
}, },
// Install, re-use name // Install, re-use name
{ {
name: "install and reuse name", name: "install and replace release",
args: []string{"testdata/testcharts/alpine"}, args: []string{"testdata/testcharts/alpine"},
flags: strings.Split("--name aeneas --reuse-name", " "), flags: strings.Split("--name aeneas --replace", " "),
expected: "aeneas", expected: "aeneas",
resp: releaseMock(&releaseOptions{name: "aeneas"}), resp: releaseMock(&releaseOptions{name: "aeneas"}),
}, },

@ -240,10 +240,12 @@ func (s *releaseServer) uniqName(start string, reuse bool) (string, error) {
if start != "" { if start != "" {
if rel, err := s.env.Releases.Read(start); err == storage.ErrNotFound { if rel, err := s.env.Releases.Read(start); err == storage.ErrNotFound {
return start, nil return start, nil
} else if reuse && rel.Info.Status.Code == release.Status_DELETED { } else if st := rel.Info.Status.Code; reuse && (st == release.Status_DELETED || st == release.Status_FAILED) {
// Allowe re-use of names if the previous release is marked deleted. // Allowe re-use of names if the previous release is marked deleted.
log.Printf("reusing name %q", start) log.Printf("reusing name %q", start)
return start, nil return start, nil
} else if reuse {
return "", errors.New("cannot re-use a name that is still in use")
} }
return "", fmt.Errorf("a release named %q already exists", start) return "", fmt.Errorf("a release named %q already exists", start)

Loading…
Cancel
Save