github.com/terraform-modules-krish/terratest@v0.29.0/modules/helm/upgrade.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/terraform-modules-krish/terratest/modules/files" 8 "github.com/terraform-modules-krish/terratest/modules/testing" 9 "github.com/stretchr/testify/require" 10 ) 11 12 // Upgrade will upgrade the release and chart will be deployed with the lastest configuration. This will fail 13 // the test if there is an error. 14 func Upgrade(t testing.TestingT, options *Options, chart string, releaseName string) { 15 require.NoError(t, UpgradeE(t, options, chart, releaseName)) 16 } 17 18 // UpgradeE will upgrade the release and chart will be deployed with the lastest configuration. 19 func UpgradeE(t testing.TestingT, options *Options, chart string, releaseName string) error { 20 // If the chart refers to a path, convert to absolute path. Otherwise, pass straight through as it may be a remote 21 // chart. 22 if files.FileExists(chart) { 23 absChartDir, err := filepath.Abs(chart) 24 if err != nil { 25 return errors.WithStackTrace(err) 26 } 27 chart = absChartDir 28 } 29 30 var err error 31 args := []string{} 32 args = append(args, getNamespaceArgs(options)...) 33 args, err = getValuesArgsE(t, options, args...) 34 if err != nil { 35 return err 36 } 37 38 args = append(args, "--install", releaseName, chart) 39 _, err = RunHelmCommandAndGetOutputE(t, options, "upgrade", args...) 40 return err 41 }