Rename Delete to Uninstall [#4]
Helm3 renamed its delete command to uninstall. We should still accept helm_command=delete for drone-helm compatibility, but the internals should use Helm's preferred name.
This commit is contained in:
51
internal/run/uninstall.go
Normal file
51
internal/run/uninstall.go
Normal file
@@ -0,0 +1,51 @@
|
||||
package run
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// Uninstall is an execution step that calls `helm uninstall` when executed.
|
||||
type Uninstall struct {
|
||||
Release string
|
||||
DryRun bool
|
||||
cmd cmd
|
||||
}
|
||||
|
||||
// Execute executes the `helm uninstall` command.
|
||||
func (u *Uninstall) Execute(_ Config) error {
|
||||
return u.cmd.Run()
|
||||
}
|
||||
|
||||
// Prepare gets the Uninstall ready to execute.
|
||||
func (u *Uninstall) Prepare(cfg Config) error {
|
||||
if u.Release == "" {
|
||||
return fmt.Errorf("release is required")
|
||||
}
|
||||
|
||||
args := []string{"--kubeconfig", cfg.KubeConfig}
|
||||
|
||||
if cfg.Namespace != "" {
|
||||
args = append(args, "--namespace", cfg.Namespace)
|
||||
}
|
||||
if cfg.Debug {
|
||||
args = append(args, "--debug")
|
||||
}
|
||||
|
||||
args = append(args, "uninstall")
|
||||
|
||||
if u.DryRun {
|
||||
args = append(args, "--dry-run")
|
||||
}
|
||||
|
||||
args = append(args, u.Release)
|
||||
|
||||
u.cmd = command(helmBin, args...)
|
||||
u.cmd.Stdout(cfg.Stdout)
|
||||
u.cmd.Stderr(cfg.Stderr)
|
||||
|
||||
if cfg.Debug {
|
||||
fmt.Fprintf(cfg.Stderr, "Generated command: '%s'\n", u.cmd.String())
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user