mirror of
https://github.com/helm/helm.git
synced 2026-05-28 04:35:48 -04:00
parent
be053f3c05
commit
4593111892
3 changed files with 8 additions and 6 deletions
|
|
@ -59,7 +59,7 @@ type installCmd struct {
|
|||
chartPath string
|
||||
dryRun bool
|
||||
disableHooks bool
|
||||
reuseName bool
|
||||
replace bool
|
||||
out io.Writer
|
||||
client helm.Interface
|
||||
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.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.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")
|
||||
return cmd
|
||||
}
|
||||
|
|
@ -119,7 +119,7 @@ func (i *installCmd) run() error {
|
|||
helm.ValueOverrides(rawVals),
|
||||
helm.ReleaseName(i.name),
|
||||
helm.InstallDryRun(i.dryRun),
|
||||
helm.InstallReuseName(i.reuseName),
|
||||
helm.InstallReuseName(i.replace),
|
||||
helm.InstallDisableHooks(i.disableHooks))
|
||||
if err != nil {
|
||||
return prettyError(err)
|
||||
|
|
|
|||
|
|
@ -59,9 +59,9 @@ func TestInstall(t *testing.T) {
|
|||
},
|
||||
// Install, re-use name
|
||||
{
|
||||
name: "install and reuse name",
|
||||
name: "install and replace release",
|
||||
args: []string{"testdata/testcharts/alpine"},
|
||||
flags: strings.Split("--name aeneas --reuse-name", " "),
|
||||
flags: strings.Split("--name aeneas --replace", " "),
|
||||
expected: "aeneas",
|
||||
resp: releaseMock(&releaseOptions{name: "aeneas"}),
|
||||
},
|
||||
|
|
|
|||
|
|
@ -240,10 +240,12 @@ func (s *releaseServer) uniqName(start string, reuse bool) (string, error) {
|
|||
if start != "" {
|
||||
if rel, err := s.env.Releases.Read(start); err == storage.ErrNotFound {
|
||||
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.
|
||||
log.Printf("reusing name %q", start)
|
||||
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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue