2019-12-05 22:35:25 +00:00
|
|
|
package run
|
|
|
|
|
|
|
|
import (
|
2019-12-10 00:25:47 +00:00
|
|
|
"fmt"
|
2019-12-05 22:35:25 +00:00
|
|
|
)
|
|
|
|
|
2019-12-10 00:25:47 +00:00
|
|
|
// Upgrade is an execution step that calls `helm upgrade` when executed.
|
2019-12-09 17:56:02 +00:00
|
|
|
type Upgrade struct {
|
|
|
|
Chart string
|
|
|
|
Release string
|
2019-12-10 00:25:47 +00:00
|
|
|
|
|
|
|
ChartVersion string
|
|
|
|
Wait bool
|
|
|
|
ReuseValues bool
|
|
|
|
Timeout string
|
|
|
|
Force bool
|
|
|
|
|
|
|
|
cmd cmd
|
2019-12-09 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
2019-12-10 00:25:47 +00:00
|
|
|
// Execute executes the `helm upgrade` command.
|
|
|
|
func (u *Upgrade) Execute() error {
|
2019-12-09 17:56:02 +00:00
|
|
|
return u.cmd.Run()
|
|
|
|
}
|
|
|
|
|
2019-12-10 00:25:47 +00:00
|
|
|
// 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...)
|
2019-12-09 17:56:02 +00:00
|
|
|
}
|
2019-12-05 22:35:25 +00:00
|
|
|
|
2019-12-10 00:25:47 +00:00
|
|
|
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())
|
|
|
|
}
|
2019-12-05 22:35:25 +00:00
|
|
|
|
2019-12-10 00:25:47 +00:00
|
|
|
return nil
|
2019-12-05 22:35:25 +00:00
|
|
|
}
|