Skip to content

Commit

Permalink
refactor: remove helm Install and Lint functions
Browse files Browse the repository at this point in the history
BREAKING CHANGE:
InstallWithValues and LintWithValues should now be used in place
of Install and Lint.
  • Loading branch information
jlegrone committed Dec 9, 2018
1 parent 26a6b0d commit 2caa7d9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 32 deletions.
31 changes: 13 additions & 18 deletions pkg/chart/chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,18 @@ type Git interface {
//
// BuildDependencies builds the chart's dependencies
//
// Lint runs `helm lint` for the given chart
// LintWithValues runs `helm lint` for the given chart using the specified values file.
// Pass a zero value for valuesFile in order to run lint without specifying a values file.
//
// LintWithValues runs `helm lint` for the given chart using the specified values file
//
// Install runs `helm install` for the given chart
//
// InstallWithValues runs `helm install` for the given chart using the specified values file
// InstallWithValues runs `helm install` for the given chart using the specified values file.
// Pass a zero value for valuesFile in order to run install without specifying a values file.
//
// DeleteRelease purges the specified Helm release.
type Helm interface {
Init() error
AddRepo(name string, url string) error
BuildDependencies(chart string) error
Lint(chart string) error
LintWithValues(chart string, valuesFile string) error
Install(chart string, namespace string, release string) error
InstallWithValues(chart string, valuesFile string, namespace string, release string) error
Test(release string) error
DeleteRelease(release string)
Expand Down Expand Up @@ -245,7 +241,7 @@ func (t *Testing) InstallCharts() ([]TestResult, error) {
return t.processCharts(t.InstallChart)
}

// LintAndInstallChart first lints and then installs charts (changed, all, specific) depending on the configuration.
// LintAndInstallCharts first lints and then installs charts (changed, all, specific) depending on the configuration.
func (t *Testing) LintAndInstallCharts() ([]TestResult, error) {
return t.processCharts(t.LintAndInstallChart)
}
Expand Down Expand Up @@ -304,16 +300,15 @@ func (t *Testing) LintChart(chart string, valuesFiles []string) TestResult {
}
}

if len(valuesFiles) > 0 {
for _, valuesFile := range valuesFiles {
if err := t.helm.LintWithValues(chart, valuesFile); err != nil {
result.Error = err
break
}
}
} else {
if err := t.helm.Lint(chart); err != nil {
// Lint with defaults if no values files are specified.
if len(valuesFiles) == 0 {
valuesFiles = append(valuesFiles, "")
}

for _, valuesFile := range valuesFiles {
if err := t.helm.LintWithValues(chart, valuesFile); err != nil {
result.Error = err
break
}
}

Expand Down
10 changes: 4 additions & 6 deletions pkg/chart/chart_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,10 @@ func (l fakeLinter) Yamale(yamlFile, schemaFile string) error { return nil }

type fakeHelm struct{}

func (h fakeHelm) Init() error { return nil }
func (h fakeHelm) AddRepo(name, url string) error { return nil }
func (h fakeHelm) BuildDependencies(chart string) error { return nil }
func (h fakeHelm) Lint(chart string) error { return nil }
func (h fakeHelm) LintWithValues(chart string, valuesFile string) error { return nil }
func (h fakeHelm) Install(chart string, namespace string, release string) error { return nil }
func (h fakeHelm) Init() error { return nil }
func (h fakeHelm) AddRepo(name, url string) error { return nil }
func (h fakeHelm) BuildDependencies(chart string) error { return nil }
func (h fakeHelm) LintWithValues(chart string, valuesFile string) error { return nil }
func (h fakeHelm) InstallWithValues(chart string, valuesFile string, namespace string, release string) error {
return nil
}
Expand Down
13 changes: 5 additions & 8 deletions pkg/tool/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,13 @@ func (h Helm) BuildDependencies(chart string) error {
return h.exec.RunProcess("helm", "dependency", "build", chart)
}

func (h Helm) Lint(chart string) error {
return h.exec.RunProcess("helm", "lint", chart)
}

func (h Helm) LintWithValues(chart string, valuesFile string) error {
return h.exec.RunProcess("helm", "lint", chart, "--values", valuesFile)
}
var values []string
if valuesFile != "" {
values = []string{"--values", valuesFile}
}

func (h Helm) Install(chart string, namespace string, release string) error {
return h.InstallWithValues(chart, "", namespace, release)
return h.exec.RunProcess("helm", "lint", chart, values)
}

func (h Helm) InstallWithValues(chart string, valuesFile string, namespace string, release string) error {
Expand Down

0 comments on commit 2caa7d9

Please sign in to comment.