mirror of
https://github.com/helmfile/helmfile.git
synced 2026-10-19 09:11:37 +02:00
feat: add --force-conflicts flag support for Helm 4 (#2480)
* feat: add --force-conflicts flag support for Helm 4 Add support for Helm 4's --force-conflicts flag which forces server-side apply changes against conflicts. This flag is mutually exclusive with --force/--force-replace and only available in Helm 4. Fixes #2429 Signed-off-by: yxxhero <aiopsclub@163.com> * fix: address review comments on force-conflicts feature - Fix comment grammar: 'forces' instead of 'force' - Improve error messages to indicate both sources (releases[] and helmDefaults) - Add test case for helmDefaults.forceConflicts with Helm 3 (should error) - Update TestGenerateID expected hashes after adding ForceConflicts field to structs Signed-off-by: yxxhero <aiopsclub@163.com> --------- Signed-off-by: yxxhero <aiopsclub@163.com>
This commit is contained in:
@@ -376,6 +376,91 @@ func TestHelmState_flagsForUpgrade(t *testing.T) {
|
||||
"--namespace", "test-namespace",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "force-conflicts-helm4",
|
||||
defaults: HelmSpec{
|
||||
ForceConflicts: false,
|
||||
CreateNamespace: &disable,
|
||||
},
|
||||
version: semver.MustParse("4.0.0"),
|
||||
release: &ReleaseSpec{
|
||||
Chart: "test/chart",
|
||||
Version: "0.1",
|
||||
ForceConflicts: &enable,
|
||||
Name: "test-charts",
|
||||
Namespace: "test-namespace",
|
||||
},
|
||||
want: []string{
|
||||
"--version", "0.1",
|
||||
"--force-conflicts",
|
||||
"--namespace", "test-namespace",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "force-conflicts-from-default-helm4",
|
||||
defaults: HelmSpec{
|
||||
ForceConflicts: true,
|
||||
CreateNamespace: &disable,
|
||||
},
|
||||
version: semver.MustParse("4.0.0"),
|
||||
release: &ReleaseSpec{
|
||||
Chart: "test/chart",
|
||||
Version: "0.1",
|
||||
Name: "test-charts",
|
||||
Namespace: "test-namespace",
|
||||
},
|
||||
want: []string{
|
||||
"--version", "0.1",
|
||||
"--force-conflicts",
|
||||
"--namespace", "test-namespace",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "force-conflicts-helm3-error",
|
||||
defaults: HelmSpec{
|
||||
CreateNamespace: &disable,
|
||||
},
|
||||
version: semver.MustParse("3.10.0"),
|
||||
release: &ReleaseSpec{
|
||||
Chart: "test/chart",
|
||||
Version: "0.1",
|
||||
ForceConflicts: &enable,
|
||||
Name: "test-charts",
|
||||
Namespace: "test-namespace",
|
||||
},
|
||||
wantErr: "forceConflicts requires Helm 4 or greater (set via releases[].forceConflicts or helmDefaults.forceConflicts)",
|
||||
},
|
||||
{
|
||||
name: "force-conflicts-from-default-helm3-error",
|
||||
defaults: HelmSpec{
|
||||
ForceConflicts: true,
|
||||
CreateNamespace: &disable,
|
||||
},
|
||||
version: semver.MustParse("3.10.0"),
|
||||
release: &ReleaseSpec{
|
||||
Chart: "test/chart",
|
||||
Version: "0.1",
|
||||
Name: "test-charts",
|
||||
Namespace: "test-namespace",
|
||||
},
|
||||
wantErr: "forceConflicts requires Helm 4 or greater (set via releases[].forceConflicts or helmDefaults.forceConflicts)",
|
||||
},
|
||||
{
|
||||
name: "force-and-force-conflicts-mutually-exclusive-helm4",
|
||||
defaults: HelmSpec{
|
||||
CreateNamespace: &disable,
|
||||
},
|
||||
version: semver.MustParse("4.0.0"),
|
||||
release: &ReleaseSpec{
|
||||
Chart: "test/chart",
|
||||
Version: "0.1",
|
||||
Force: &enable,
|
||||
ForceConflicts: &enable,
|
||||
Name: "test-charts",
|
||||
Namespace: "test-namespace",
|
||||
},
|
||||
wantErr: "force and forceConflicts are mutually exclusive (check both releases[].force/forceConflicts and helmDefaults.force/forceConflicts)",
|
||||
},
|
||||
{
|
||||
name: "recreate-pods",
|
||||
defaults: HelmSpec{
|
||||
|
||||
Reference in New Issue
Block a user