Initialize run.Configs in the NewSTEP functions [#67]
This fixes the run package's leaky abstraction; other packages no longer need to know or care that run.Config even exists. Note that since the various Steps now depend on having a non-nil pointer to a run.Config, it's unsafe (or at least risky) to initialize them directly. They should be created with their NewSTEPNAME functions. All their fields are now private, to reflect this.
This commit is contained in:
@@ -7,22 +7,24 @@ import (
|
||||
|
||||
// Lint is an execution step that calls `helm lint` when executed.
|
||||
type Lint struct {
|
||||
Chart string
|
||||
Values string
|
||||
StringValues string
|
||||
ValuesFiles []string
|
||||
Strict bool
|
||||
*config
|
||||
chart string
|
||||
values string
|
||||
stringValues string
|
||||
valuesFiles []string
|
||||
strict bool
|
||||
cmd cmd
|
||||
}
|
||||
|
||||
// NewLint creates a Lint using fields from the given Config. No validation is performed at this time.
|
||||
func NewLint(cfg env.Config) *Lint {
|
||||
return &Lint{
|
||||
Chart: cfg.Chart,
|
||||
Values: cfg.Values,
|
||||
StringValues: cfg.StringValues,
|
||||
ValuesFiles: cfg.ValuesFiles,
|
||||
Strict: cfg.LintStrictly,
|
||||
config: newConfig(cfg),
|
||||
chart: cfg.Chart,
|
||||
values: cfg.Values,
|
||||
stringValues: cfg.StringValues,
|
||||
valuesFiles: cfg.ValuesFiles,
|
||||
strict: cfg.LintStrictly,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,43 +34,43 @@ func (l *Lint) Execute() error {
|
||||
}
|
||||
|
||||
// Prepare gets the Lint ready to execute.
|
||||
func (l *Lint) Prepare(cfg Config) error {
|
||||
if l.Chart == "" {
|
||||
func (l *Lint) Prepare() error {
|
||||
if l.chart == "" {
|
||||
return fmt.Errorf("chart is required")
|
||||
}
|
||||
|
||||
args := make([]string, 0)
|
||||
|
||||
if cfg.Namespace != "" {
|
||||
args = append(args, "--namespace", cfg.Namespace)
|
||||
if l.namespace != "" {
|
||||
args = append(args, "--namespace", l.namespace)
|
||||
}
|
||||
if cfg.Debug {
|
||||
if l.debug {
|
||||
args = append(args, "--debug")
|
||||
}
|
||||
|
||||
args = append(args, "lint")
|
||||
|
||||
if l.Values != "" {
|
||||
args = append(args, "--set", l.Values)
|
||||
if l.values != "" {
|
||||
args = append(args, "--set", l.values)
|
||||
}
|
||||
if l.StringValues != "" {
|
||||
args = append(args, "--set-string", l.StringValues)
|
||||
if l.stringValues != "" {
|
||||
args = append(args, "--set-string", l.stringValues)
|
||||
}
|
||||
for _, vFile := range l.ValuesFiles {
|
||||
for _, vFile := range l.valuesFiles {
|
||||
args = append(args, "--values", vFile)
|
||||
}
|
||||
if l.Strict {
|
||||
if l.strict {
|
||||
args = append(args, "--strict")
|
||||
}
|
||||
|
||||
args = append(args, l.Chart)
|
||||
args = append(args, l.chart)
|
||||
|
||||
l.cmd = command(helmBin, args...)
|
||||
l.cmd.Stdout(cfg.Stdout)
|
||||
l.cmd.Stderr(cfg.Stderr)
|
||||
l.cmd.Stdout(l.stdout)
|
||||
l.cmd.Stderr(l.stderr)
|
||||
|
||||
if cfg.Debug {
|
||||
fmt.Fprintf(cfg.Stderr, "Generated command: '%s'\n", l.cmd.String())
|
||||
if l.debug {
|
||||
fmt.Fprintf(l.stderr, "Generated command: '%s'\n", l.cmd.String())
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user