-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
upgrade.go
46 lines (40 loc) · 1.41 KB
/
upgrade.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
package helm
import (
"path/filepath"
"github.com/gruntwork-io/gruntwork-cli/errors"
"github.com/gruntwork-io/terratest/modules/files"
"github.com/gruntwork-io/terratest/modules/testing"
"github.com/stretchr/testify/require"
)
// Upgrade will upgrade the release and chart will be deployed with the lastest configuration. This will fail
// the test if there is an error.
func Upgrade(t testing.TestingT, options *Options, chart string, releaseName string) {
require.NoError(t, UpgradeE(t, options, chart, releaseName))
}
// UpgradeE will upgrade the release and chart will be deployed with the lastest configuration.
func UpgradeE(t testing.TestingT, 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
}
var err error
args := []string{}
if options.ExtraArgs != nil {
if upgradeArgs, ok := options.ExtraArgs["upgrade"]; ok {
args = append(args, upgradeArgs...)
}
}
args = append(args, getNamespaceArgs(options)...)
args, err = getValuesArgsE(t, options, args...)
if err != nil {
return err
}
args = append(args, "--install", releaseName, chart)
_, err = RunHelmCommandAndGetOutputE(t, options, "upgrade", args...)
return err
}