Skip to content

Commit 845d3be

Browse files
ldmonsterPavel Okhlopkov
and
Pavel Okhlopkov
authored
change (#734)
Signed-off-by: Pavel Okhlopkov <[email protected]> Co-authored-by: Pavel Okhlopkov <[email protected]>
1 parent 00480c6 commit 845d3be

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

pkg/kube/object_patch/operation.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -186,22 +186,22 @@ func NewFromOperationSpec(spec OperationSpec) sdkpkg.PatchCollectorOperation {
186186
spec.JQFilter,
187187
spec.ApiVersion, spec.Kind, spec.Namespace, spec.Name,
188188
WithSubresource(spec.Subresource),
189-
WithIgnoreMissingObject(spec.IgnoreMissingObject),
190-
WithIgnoreHookError(spec.IgnoreHookError),
189+
withIgnoreMissingObject(spec.IgnoreMissingObject),
190+
withIgnoreHookError(spec.IgnoreHookError),
191191
)
192192
case MergePatch:
193193
return NewMergePatchOperation(spec.MergePatch,
194194
spec.ApiVersion, spec.Kind, spec.Namespace, spec.Name,
195195
WithSubresource(spec.Subresource),
196-
WithIgnoreMissingObject(spec.IgnoreMissingObject),
197-
WithIgnoreHookError(spec.IgnoreHookError),
196+
withIgnoreMissingObject(spec.IgnoreMissingObject),
197+
withIgnoreHookError(spec.IgnoreHookError),
198198
)
199199
case JSONPatch:
200200
return NewJSONPatchOperation(spec.JSONPatch,
201201
spec.ApiVersion, spec.Kind, spec.Namespace, spec.Name,
202202
WithSubresource(spec.Subresource),
203-
WithIgnoreMissingObject(spec.IgnoreMissingObject),
204-
WithIgnoreHookError(spec.IgnoreHookError),
203+
withIgnoreMissingObject(spec.IgnoreMissingObject),
204+
withIgnoreHookError(spec.IgnoreHookError),
205205
)
206206
}
207207

pkg/kube/object_patch/options.go

+10-2
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,22 @@ func WithSubresource(subresource string) Option {
1616
}
1717
}
1818

19-
func WithIgnoreMissingObject(ignore bool) Option {
19+
func withIgnoreMissingObject(ignore bool) Option {
2020
return func(o sdkpkg.PatchCollectorOptionApplier) {
2121
o.WithIgnoreMissingObject(ignore)
2222
}
2323
}
2424

25-
func WithIgnoreHookError(ignore bool) Option {
25+
func WithIgnoreMissingObject() Option {
26+
return withIgnoreMissingObject(true)
27+
}
28+
29+
func withIgnoreHookError(ignore bool) Option {
2630
return func(o sdkpkg.PatchCollectorOptionApplier) {
2731
o.WithIgnoreHookError(ignore)
2832
}
2933
}
34+
35+
func WithIgnoreHookError() Option {
36+
return withIgnoreHookError(true)
37+
}

pkg/kube/object_patch/patch_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ data:
145145
return patcher.ExecuteOperation(NewMergePatchOperation(
146146
fmt.Sprintf(`{"data":{"%s":"%s"}}`, newField, newValue),
147147
"v1", "ConfigMap", namespace, missingName,
148-
WithIgnoreMissingObject(true),
148+
WithIgnoreMissingObject(),
149149
))
150150
},
151151
shouldNotAdd,
@@ -295,7 +295,7 @@ mergePatch: |
295295
return patcher.ExecuteOperation(NewJSONPatchOperation(
296296
fmt.Sprintf(`[{ "op": "add", "path": "/data/%s", "value": "%s"}]`, newField, newValue),
297297
"v1", "ConfigMap", namespace, missingName,
298-
WithIgnoreMissingObject(true),
298+
WithIgnoreMissingObject(),
299299
))
300300
},
301301
shouldNotAdd,
@@ -412,7 +412,7 @@ jsonPatch: |
412412
return patcher.ExecuteOperation(NewPatchWithMutatingFuncOperation(
413413
filter,
414414
"v1", "ConfigMap", namespace, missingName,
415-
WithIgnoreMissingObject(true),
415+
WithIgnoreMissingObject(),
416416
))
417417
},
418418
shouldNotAdd,

0 commit comments

Comments
 (0)