I'm vacillating about the choice to have separate Config structs in the `helm` and `run` packages. I can't tell whether it's "good separation of concerns" or "cumbersome and over-engineered." It seems appropriate at the moment, though.
44 lines
793 B
Go
44 lines
793 B
Go
package run
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
// Upgrade is an execution step that calls `helm upgrade` when executed.
|
|
type Upgrade struct {
|
|
Chart string
|
|
Release string
|
|
|
|
ChartVersion string
|
|
Wait bool
|
|
ReuseValues bool
|
|
Timeout string
|
|
Force bool
|
|
|
|
cmd cmd
|
|
}
|
|
|
|
// Execute executes the `helm upgrade` command.
|
|
func (u *Upgrade) Execute() error {
|
|
return u.cmd.Run()
|
|
}
|
|
|
|
// Prepare gets the Upgrade ready to execute.
|
|
func (u *Upgrade) Prepare(cfg Config) error {
|
|
args := []string{"upgrade", "--install", u.Release, u.Chart}
|
|
|
|
if cfg.Debug {
|
|
args = append([]string{"--debug"}, args...)
|
|
}
|
|
|
|
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
|
|
}
|