|
|
@ -33,7 +33,9 @@ import (
|
|
|
|
|
|
|
|
|
|
|
|
func TestUpgradeCmd(t *testing.T) {
|
|
|
|
func TestUpgradeCmd(t *testing.T) {
|
|
|
|
tmpChart, _ := ioutil.TempDir("testdata", "tmp")
|
|
|
|
tmpChart, _ := ioutil.TempDir("testdata", "tmp")
|
|
|
|
|
|
|
|
tmpChart2, _ := ioutil.TempDir("testdata", "tmp2")
|
|
|
|
defer os.RemoveAll(tmpChart)
|
|
|
|
defer os.RemoveAll(tmpChart)
|
|
|
|
|
|
|
|
defer os.RemoveAll(tmpChart2)
|
|
|
|
cfile := &chart.Metadata{
|
|
|
|
cfile := &chart.Metadata{
|
|
|
|
Name: "testUpgradeChart",
|
|
|
|
Name: "testUpgradeChart",
|
|
|
|
Description: "A Helm chart for Kubernetes",
|
|
|
|
Description: "A Helm chart for Kubernetes",
|
|
|
@ -91,6 +93,23 @@ func TestUpgradeCmd(t *testing.T) {
|
|
|
|
t.Errorf("Error loading chart with missing dependencies: %v", err)
|
|
|
|
t.Errorf("Error loading chart with missing dependencies: %v", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// update chart version
|
|
|
|
|
|
|
|
cfile = &chart.Metadata{
|
|
|
|
|
|
|
|
Name: "testUpgradeChartAppVersion",
|
|
|
|
|
|
|
|
Description: "A Helm chart for Kubernetes",
|
|
|
|
|
|
|
|
Version: "0.1.0",
|
|
|
|
|
|
|
|
OverrideAppVersion: true,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
chartPath, err = chartutil.Create(cfile, tmpChart2)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
t.Errorf("Error creating chart: %v", err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ch4, err := chartutil.Load(chartPath)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
t.Errorf("Error loading updated chart: %v", err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
tests := []releaseCase{
|
|
|
|
tests := []releaseCase{
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: "upgrade a release",
|
|
|
|
name: "upgrade a release",
|
|
|
@ -184,13 +203,17 @@ func TestUpgradeCmd(t *testing.T) {
|
|
|
|
err: true,
|
|
|
|
err: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: "upgrade with app-version (allow)",
|
|
|
|
name: "upgrade with app-version (allow)",
|
|
|
|
args: []string{"testdata/testcharts/alpine-app-version"},
|
|
|
|
resp: helm.ReleaseMock(&helm.MockReleaseOptions{Name: "funny-bunny", Version: 2, Chart: ch4}),
|
|
|
|
flags: []string{"--app-version", "1.0.1"},
|
|
|
|
expected: "Release \"funny-bunny\" has been upgraded. Happy Helming!\n",
|
|
|
|
|
|
|
|
flags: []string{"--app-version", "1.0.1"},
|
|
|
|
|
|
|
|
args: []string{"funny-bunny", chartPath},
|
|
|
|
|
|
|
|
rels: []*release.Release{helm.ReleaseMock(&helm.MockReleaseOptions{Name: "funny-bunny", Version: 2, Chart: ch4})},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: "upgrade with app-version (not allow)",
|
|
|
|
name: "upgrade with app-version (not allow)",
|
|
|
|
args: []string{"testdata/testcharts/alpine"},
|
|
|
|
args: []string{"testdata/testcharts/alpine"},
|
|
|
|
|
|
|
|
resp: helm.ReleaseMock(&helm.MockReleaseOptions{Name: "bonkers-bunny", Version: 2, Chart: ch3}),
|
|
|
|
flags: []string{"--app-version", "1.0.1"},
|
|
|
|
flags: []string{"--app-version", "1.0.1"},
|
|
|
|
err: true,
|
|
|
|
err: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|