161960e55e
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.
52 lines
963 B
Go
52 lines
963 B
Go
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
|
|
}
|