-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
install.go
48 lines (42 loc) · 1.55 KB
/
install.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package helm
import (
"path/filepath"
"testing"
"github.com/gruntwork-io/gruntwork-cli/errors"
"github.com/stretchr/testify/require"
"github.com/gruntwork-io/terratest/modules/files"
)
// Install will install the selected helm chart with the provided options under the given release name. This will fail
// the test if there is an error.
func Install(t *testing.T, options *Options, chart string, releaseName string) {
require.NoError(t, InstallE(t, options, chart, releaseName))
}
// InstallE will install the selected helm chart with the provided options under the given release name.
func InstallE(t *testing.T, options *Options, chart string, releaseName string) error {
// If the chart refers to a path, convert to absolute path. Otherwise, pass straight through as it may be a remote
// chart.
if files.FileExists(chart) {
absChartDir, err := filepath.Abs(chart)
if err != nil {
return errors.WithStackTrace(err)
}
chart = absChartDir
}
// Now call out to helm install to install the charts with the provided options
// Declare err here so that we can update args later
var err error
args := []string{}
if options.KubectlOptions != nil && options.KubectlOptions.Namespace != "" {
args = append(args, "--namespace", options.KubectlOptions.Namespace)
}
if options.Version != "" {
args = append(args, "--version", options.Version)
}
args, err = getValuesArgsE(t, options, args...)
if err != nil {
return err
}
args = append(args, "-n", releaseName, chart)
_, err = RunHelmCommandAndGetOutputE(t, options, "install", args...)
return err
}