-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
upgrade.go
41 lines (35 loc) · 1.28 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
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{}
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
}