mirror of
https://github.com/helmfile/helmfile.git
synced 2026-10-17 20:07:08 +02:00
Append --force-update for specific helm versions. (#1494)
* Parse and process helm version using github.com/Masterminds/semver/v3. * Add --force-update only when Helm version >= 3.3.2, < 3.3.4. See: https://github.com/helm/helm/pull/8777. * Add test cases.
This commit is contained in:
@@ -2,18 +2,19 @@ package state
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/Masterminds/semver"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/Masterminds/semver/v3"
|
||||
goversion "github.com/hashicorp/go-version"
|
||||
"github.com/r3labs/diff"
|
||||
"github.com/roboll/helmfile/pkg/app/version"
|
||||
"github.com/roboll/helmfile/pkg/helmexec"
|
||||
"go.uber.org/zap"
|
||||
"gopkg.in/yaml.v2"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type ChartMeta struct {
|
||||
|
||||
+1
-1
@@ -2069,7 +2069,7 @@ func (st *HelmState) flagsForUpgrade(helm helmexec.Interface, release *ReleaseSp
|
||||
|
||||
if release.CreateNamespace != nil && *release.CreateNamespace ||
|
||||
release.CreateNamespace == nil && (st.HelmDefaults.CreateNamespace == nil || *st.HelmDefaults.CreateNamespace) {
|
||||
if helm.IsVersionAtLeast(3, 2, 0) {
|
||||
if helm.IsVersionAtLeast("3.2.0") {
|
||||
flags = append(flags, "--create-namespace")
|
||||
} else if release.CreateNamespace != nil || st.HelmDefaults.CreateNamespace != nil {
|
||||
// createNamespace was set explicitly, but not running supported version of helm - error
|
||||
|
||||
+7
-26
@@ -8,6 +8,7 @@ import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/Masterminds/semver/v3"
|
||||
"github.com/roboll/helmfile/pkg/exectest"
|
||||
"github.com/roboll/helmfile/pkg/helmexec"
|
||||
"github.com/roboll/helmfile/pkg/testhelper"
|
||||
@@ -165,7 +166,7 @@ func TestHelmState_flagsForUpgrade(t *testing.T) {
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
version *helmexec.Version
|
||||
version *semver.Version
|
||||
defaults HelmSpec
|
||||
release *ReleaseSpec
|
||||
want []string
|
||||
@@ -582,11 +583,7 @@ func TestHelmState_flagsForUpgrade(t *testing.T) {
|
||||
defaults: HelmSpec{
|
||||
Verify: false,
|
||||
},
|
||||
version: &helmexec.Version{
|
||||
Major: 3,
|
||||
Minor: 2,
|
||||
Patch: 0,
|
||||
},
|
||||
version: semver.MustParse("3.2.0"),
|
||||
release: &ReleaseSpec{
|
||||
Chart: "test/chart",
|
||||
Version: "0.1",
|
||||
@@ -606,11 +603,7 @@ func TestHelmState_flagsForUpgrade(t *testing.T) {
|
||||
Verify: false,
|
||||
CreateNamespace: &disable,
|
||||
},
|
||||
version: &helmexec.Version{
|
||||
Major: 3,
|
||||
Minor: 2,
|
||||
Patch: 0,
|
||||
},
|
||||
version: semver.MustParse("3.2.0"),
|
||||
release: &ReleaseSpec{
|
||||
Chart: "test/chart",
|
||||
Version: "0.1",
|
||||
@@ -629,11 +622,7 @@ func TestHelmState_flagsForUpgrade(t *testing.T) {
|
||||
Verify: false,
|
||||
CreateNamespace: &disable,
|
||||
},
|
||||
version: &helmexec.Version{
|
||||
Major: 3,
|
||||
Minor: 2,
|
||||
Patch: 0,
|
||||
},
|
||||
version: semver.MustParse("3.2.0"),
|
||||
release: &ReleaseSpec{
|
||||
Chart: "test/chart",
|
||||
Version: "0.1",
|
||||
@@ -654,11 +643,7 @@ func TestHelmState_flagsForUpgrade(t *testing.T) {
|
||||
Verify: false,
|
||||
CreateNamespace: &enable,
|
||||
},
|
||||
version: &helmexec.Version{
|
||||
Major: 3,
|
||||
Minor: 2,
|
||||
Patch: 0,
|
||||
},
|
||||
version: semver.MustParse("3.2.0"),
|
||||
release: &ReleaseSpec{
|
||||
Chart: "test/chart",
|
||||
Version: "0.1",
|
||||
@@ -678,11 +663,7 @@ func TestHelmState_flagsForUpgrade(t *testing.T) {
|
||||
Verify: false,
|
||||
CreateNamespace: &enable,
|
||||
},
|
||||
version: &helmexec.Version{
|
||||
Major: 2,
|
||||
Minor: 16,
|
||||
Patch: 0,
|
||||
},
|
||||
version: semver.MustParse("2.16.0"),
|
||||
release: &ReleaseSpec{
|
||||
Chart: "test/chart",
|
||||
Version: "0.1",
|
||||
|
||||
Reference in New Issue
Block a user