Skip to content

Commit 2ce3093

Browse files
committed
Add karg support for patch --server-side
1 parent fc791b5 commit 2ce3093

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

pkg/pipes/karg/karg.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ const (
241241
)
242242

243243
// PatchType represents the "--type=json|merge|strategic" option on the patch command.
244+
// NOTE: As a special case, an "apply" patch will produce a "--server-side" option instead.
244245
type PatchType string
245246

246247
func (o PatchType) patchCmd(cmd *exec.Cmd) { o.kubectlCmd(cmd) }
@@ -254,6 +255,8 @@ func (o PatchType) kubectlCmd(cmd *exec.Cmd) {
254255
cmd.Args = append(cmd.Args, "--type=merge")
255256
case "application/strategic-merge-patch+json":
256257
cmd.Args = append(cmd.Args, "--type=strategic")
258+
case "application/apply-patch+yaml":
259+
cmd.Args = append(cmd.Args, "--server-side")
257260
default:
258261
cmd.Args = append(cmd.Args, "--type="+string(o))
259262
}
@@ -266,6 +269,16 @@ const (
266269
PatchTypeStrategic PatchType = "strategic"
267270
)
268271

272+
// ServerSide represents the "--server-side" option on the patch command.
273+
type ServerSide bool
274+
275+
func (o ServerSide) patchCmd(cmd *exec.Cmd) { o.kubectlCmd(cmd) }
276+
func (o ServerSide) kubectlCmd(cmd *exec.Cmd) {
277+
if o {
278+
cmd.Args = append(cmd.Args, "--server-side")
279+
}
280+
}
281+
269282
// Patch represents the "--patch" option on the patch command.
270283
type Patch string
271284

0 commit comments

Comments
 (0)