File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,11 @@ import (
23
23
"k8s.io/apimachinery/pkg/util/strategicpatch"
24
24
)
25
25
26
+ var (
27
+ // Apply uses server-side apply to patch the given object.
28
+ Apply = applyPatch {}
29
+ )
30
+
26
31
type patch struct {
27
32
patchType types.PatchType
28
33
data []byte
@@ -72,3 +77,21 @@ func (s *mergeFromPatch) Data(obj runtime.Object) ([]byte, error) {
72
77
func MergeFrom (obj runtime.Object ) Patch {
73
78
return & mergeFromPatch {obj }
74
79
}
80
+
81
+ // applyPatch uses server-side apply to patch the object.
82
+ type applyPatch struct {}
83
+
84
+ // Type implements Patch.
85
+ func (p applyPatch ) Type () types.PatchType {
86
+ // TODO(directxman12): when we update to 1.14, just use types.ApplyPatch
87
+ return "application/apply-patch+yaml"
88
+ }
89
+
90
+ // Data implements Patch.
91
+ func (p applyPatch ) Data (obj runtime.Object ) ([]byte , error ) {
92
+ // NB(directxman12): we might techically want to be using an actual encoder
93
+ // here (in case some more performant encoder is introduced) but this is
94
+ // correct and sufficient for our uses (it's what the JSON serializer in
95
+ // client-go does, more-or-less).
96
+ return json .Marshal (obj )
97
+ }
You can’t perform that action at this time.
0 commit comments