2019-12-18 00:21:45 +00:00
|
|
|
package run
|
|
|
|
|
|
|
|
import (
|
2019-12-18 00:55:01 +00:00
|
|
|
"fmt"
|
2019-12-18 00:21:45 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Lint is an execution step that calls `helm lint` when executed.
|
|
|
|
type Lint struct {
|
|
|
|
Chart string
|
2019-12-19 19:09:39 +00:00
|
|
|
cmd cmd
|
2019-12-18 00:21:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Execute executes the `helm lint` command.
|
|
|
|
func (l *Lint) Execute(_ Config) error {
|
|
|
|
return l.cmd.Run()
|
|
|
|
}
|
|
|
|
|
|
|
|
// Prepare gets the Lint ready to execute.
|
2019-12-20 18:05:50 +00:00
|
|
|
// Note: mandatory settings are documented in README.md, and the full list of settings is in docs/lint_settings.yml.
|
|
|
|
// Any additions or deletions here should be reflected there.
|
2019-12-18 00:21:45 +00:00
|
|
|
func (l *Lint) Prepare(cfg Config) error {
|
2019-12-18 01:00:34 +00:00
|
|
|
if l.Chart == "" {
|
|
|
|
return fmt.Errorf("chart is required")
|
|
|
|
}
|
|
|
|
|
2019-12-18 00:55:01 +00:00
|
|
|
args := make([]string, 0)
|
|
|
|
|
2019-12-18 18:38:33 +00:00
|
|
|
if cfg.Namespace != "" {
|
|
|
|
args = append(args, "--namespace", cfg.Namespace)
|
|
|
|
}
|
2019-12-18 00:55:01 +00:00
|
|
|
if cfg.Debug {
|
|
|
|
args = append(args, "--debug")
|
|
|
|
}
|
|
|
|
|
|
|
|
args = append(args, "lint")
|
2019-12-18 00:41:09 +00:00
|
|
|
|
|
|
|
if cfg.Values != "" {
|
|
|
|
args = append(args, "--set", cfg.Values)
|
|
|
|
}
|
|
|
|
if cfg.StringValues != "" {
|
|
|
|
args = append(args, "--set-string", cfg.StringValues)
|
|
|
|
}
|
|
|
|
for _, vFile := range cfg.ValuesFiles {
|
|
|
|
args = append(args, "--values", vFile)
|
|
|
|
}
|
|
|
|
|
|
|
|
args = append(args, l.Chart)
|
2019-12-18 00:21:45 +00:00
|
|
|
|
|
|
|
l.cmd = command(helmBin, args...)
|
|
|
|
l.cmd.Stdout(cfg.Stdout)
|
|
|
|
l.cmd.Stderr(cfg.Stderr)
|
|
|
|
|
2019-12-18 00:55:01 +00:00
|
|
|
if cfg.Debug {
|
|
|
|
fmt.Fprintf(cfg.Stderr, "Generated command: '%s'\n", l.cmd.String())
|
|
|
|
}
|
|
|
|
|
2019-12-18 00:21:45 +00:00
|
|
|
return nil
|
|
|
|
}
|