Implement the various values flags in lint [#3]

This commit is contained in:
Erin Call 2019-12-17 16:41:09 -08:00
parent 991bbf97b4
commit 51800c18d7
No known key found for this signature in database
GPG key ID: 4071FF6C15B8DAD1
2 changed files with 45 additions and 1 deletions

View file

@ -18,7 +18,19 @@ func (l *Lint) Execute(_ Config) error {
// Prepare gets the Lint ready to execute.
func (l *Lint) Prepare(cfg Config) error {
args := []string{"lint", l.Chart}
args := []string{"lint"}
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)
l.cmd = command(helmBin, args...)
l.cmd.Stdout(cfg.Stdout)

View file

@ -56,3 +56,35 @@ func (suite *LintTestSuite) TestPrepareAndExecute() {
suite.Require().Nil(err)
l.Execute(cfg)
}
func (suite *LintTestSuite) TestPrepareWithLintFlags() {
defer suite.ctrl.Finish()
cfg := Config{
Values: "width=5",
StringValues: "version=2.0",
ValuesFiles: []string{"/usr/local/underrides", "/usr/local/overrides"},
}
l := Lint{
Chart: "./uk/top_40",
}
command = func(path string, args ...string) cmd {
suite.Equal(helmBin, path)
suite.Equal([]string{"lint",
"--set", "width=5",
"--set-string", "version=2.0",
"--values", "/usr/local/underrides",
"--values", "/usr/local/overrides",
"./uk/top_40"}, args)
return suite.mockCmd
}
suite.mockCmd.EXPECT().Stdout(gomock.Any())
suite.mockCmd.EXPECT().Stderr(gomock.Any())
err := l.Prepare(cfg)
suite.Require().Nil(err)
}