mirror of
https://github.com/helm/helm.git
synced 2026-04-20 21:56:55 -04:00
Merge pull request #31635 from banjoh/em/fix-ssa-upgrade-install-cmd
Some checks are pending
build-test / build (push) Waiting to run
CodeQL / Analyze (push) Waiting to run
golangci-lint / golangci-lint (push) Waiting to run
release / release (push) Waiting to run
release / canary-release (push) Waiting to run
Scorecard supply-chain security / Scorecard analysis (push) Waiting to run
Some checks are pending
build-test / build (push) Waiting to run
CodeQL / Analyze (push) Waiting to run
golangci-lint / golangci-lint (push) Waiting to run
release / release (push) Waiting to run
release / canary-release (push) Waiting to run
Scorecard supply-chain security / Scorecard analysis (push) Waiting to run
fix(upgrade): pass --server-side flag to install when using upgrade --install
This commit is contained in:
commit
188ac4e834
2 changed files with 57 additions and 0 deletions
|
|
@ -153,6 +153,8 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
|
|||
instClient.EnableDNS = client.EnableDNS
|
||||
instClient.HideSecret = client.HideSecret
|
||||
instClient.TakeOwnership = client.TakeOwnership
|
||||
instClient.ForceConflicts = client.ForceConflicts
|
||||
instClient.ServerSideApply = client.ServerSideApply != "false"
|
||||
|
||||
if isReleaseUninstalled(versions) {
|
||||
instClient.Replace = true
|
||||
|
|
|
|||
|
|
@ -605,3 +605,58 @@ func TestUpgradeWithDryRun(t *testing.T) {
|
|||
t.Error("expected error when --hide-secret used without --dry-run")
|
||||
}
|
||||
}
|
||||
|
||||
func TestUpgradeInstallServerSideApply(t *testing.T) {
|
||||
_, _, chartPath := prepareMockRelease(t, "ssa-test")
|
||||
|
||||
defer resetEnv()()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
serverSideFlag string
|
||||
expectedApplyMethod string
|
||||
}{
|
||||
{
|
||||
name: "upgrade --install with --server-side=false uses client-side apply",
|
||||
serverSideFlag: "--server-side=false",
|
||||
expectedApplyMethod: "csa",
|
||||
},
|
||||
{
|
||||
name: "upgrade --install with --server-side=true uses server-side apply",
|
||||
serverSideFlag: "--server-side=true",
|
||||
expectedApplyMethod: "ssa",
|
||||
},
|
||||
{
|
||||
name: "upgrade --install with --server-side=auto uses server-side apply (default for new install)",
|
||||
serverSideFlag: "--server-side=auto",
|
||||
expectedApplyMethod: "ssa",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
store := storageFixture()
|
||||
releaseName := fmt.Sprintf("ssa-test-%s", tt.expectedApplyMethod)
|
||||
|
||||
cmd := fmt.Sprintf("upgrade %s --install %s '%s'", releaseName, tt.serverSideFlag, chartPath)
|
||||
_, _, err := executeActionCommandC(store, cmd)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
|
||||
rel, err := store.Get(releaseName, 1)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error getting release: %v", err)
|
||||
}
|
||||
|
||||
relV1, err := releaserToV1Release(rel)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error converting release: %v", err)
|
||||
}
|
||||
|
||||
if relV1.ApplyMethod != tt.expectedApplyMethod {
|
||||
t.Errorf("expected ApplyMethod %q, got %q", tt.expectedApplyMethod, relV1.ApplyMethod)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue