Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add server-side apply mode #651

Merged
merged 10 commits into from
Apr 27, 2022
Next Next commit
Apply changes server-side starting in v1.22
  • Loading branch information
smuth4 committed Apr 26, 2022
commit 3491327774cf54dfde166054b5c0cab4e77179bd
12 changes: 11 additions & 1 deletion pkg/kubernetes/client/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,24 @@ import (
"os/exec"
"strings"

"github.com/Masterminds/semver"

"github.com/grafana/tanka/pkg/kubernetes/manifest"
)

// Test-ability: isolate applyCtl to build and return exec.Cmd from ApplyOpts
func (k Kubectl) applyCtl(data manifest.List, opts ApplyOpts) *exec.Cmd {
argv := []string{"-f", "-"}
serverSide := !k.info.ServerVersion.LessThan(semver.MustParse("1.22.0"))
if serverSide {
argv = append(argv, "--server-side")
}
if opts.Force {
argv = append(argv, "--force")
if serverSide {
argv = append(argv, "--force-conflicts")
} else {
argv = append(argv, "--force")
}
}

if !opts.Validate {
Expand Down