feat: add support for helm 4 --server-side upgrade flag (#2641)

* feat: add support for helm 4 --server-side upgrade flag

Add support for the helm 4 upgrade flag --server-side which accepts
"true", "false", or "auto" (default "auto"). This allows users to
explicitly control server-side apply behavior, which is needed for
releases originally installed with Helm 3 and being managed with Helm 4.

The flag can be configured via:
- CLI: --server-side flag on sync, apply, and diff commands
- helmDefaults.serverSide in helmfile.yaml
- releases[].serverSide per-release override

Precedence: release-level > CLI flag > helmDefaults.
Errors are returned when serverSide is set but running Helm 3, or when
an invalid value is provided.

Closes #2640

Signed-off-by: yxxhero <aiopsclub@163.com>

* test: update TestGenerateID expected hashes for new ServerSide field

Adding ServerSide *string to ReleaseSpec changes spew's %#v output and
shifts the FNV hash used by generateValuesID. Update the hard-coded want
values to the new deterministic hashes.

Signed-off-by: yxxhero <aiopsclub@163.com>

---------

Signed-off-by: yxxhero <aiopsclub@163.com>
This commit is contained in:
yxxhero
2026-06-16 08:24:47 +08:00
committed by GitHub
parent 047fdcd17d
commit a94fdf4194
15 changed files with 265 additions and 6 deletions
+8
View File
@@ -81,6 +81,9 @@ type ApplyOptions struct {
// TakeOwnership is true if the ownership should be taken
TakeOwnership bool
// ServerSide controls the helm 4 --server-side flag. Must be "true", "false", or "auto".
ServerSide string
SyncReleaseLabels bool
// TrackMode specifies whether to use 'helm' or 'kubedog' for tracking resources
TrackMode string
@@ -298,6 +301,11 @@ func (a *ApplyImpl) TakeOwnership() bool {
return a.ApplyOptions.TakeOwnership
}
// ServerSide returns the ServerSide.
func (a *ApplyImpl) ServerSide() string {
return a.ApplyOptions.ServerSide
}
// SyncReleaseLabels returns the SyncReleaseLabels.
func (a *ApplyImpl) SyncReleaseLabels() bool {
return a.ApplyOptions.SyncReleaseLabels
+7
View File
@@ -53,6 +53,8 @@ type DiffOptions struct {
SkipSchemaValidation bool
// TakeOwnership is true if the ownership should be taken
TakeOwnership bool
// ServerSide controls the helm 4 --server-side flag. Must be "true", "false", or "auto".
ServerSide string
}
// NewDiffOptions creates a new Apply
@@ -219,3 +221,8 @@ func (t *DiffImpl) SkipSchemaValidation() bool {
func (t *DiffImpl) TakeOwnership() bool {
return t.DiffOptions.TakeOwnership
}
// ServerSide returns the ServerSide.
func (t *DiffImpl) ServerSide() string {
return t.DiffOptions.ServerSide
}
+7
View File
@@ -51,6 +51,8 @@ type SyncOptions struct {
HideNotes bool
// TakeOwnership is the take ownership flag
TakeOwnership bool
// ServerSide controls the helm 4 --server-side flag. Must be "true", "false", or "auto".
ServerSide string
// SyncReleaseLabels is the sync release labels flag
SyncReleaseLabels bool
// TrackMode specifies whether to use 'helm' or 'kubedog' for tracking resources
@@ -214,6 +216,11 @@ func (t *SyncImpl) TakeOwnership() bool {
return t.SyncOptions.TakeOwnership
}
// ServerSide returns the server-side value.
func (t *SyncImpl) ServerSide() string {
return t.SyncOptions.ServerSide
}
func (t *SyncImpl) SyncReleaseLabels() bool {
return t.SyncOptions.SyncReleaseLabels
}