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