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/json"
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
@@ -71,3 +76,21 @@ func (s *mergeFromPatch) Data(obj runtime.Object) ([]byte, error) {
71
76
func MergeFrom (obj runtime.Object ) Patch {
72
77
return & mergeFromPatch {obj }
73
78
}
79
+
80
+ // applyPatch uses server-side apply to patch the object.
81
+ type applyPatch struct {}
82
+
83
+ // Type implements Patch.
84
+ func (p applyPatch ) Type () types.PatchType {
85
+ // TODO(directxman12): when we update to 1.14, just use types.ApplyPatch
86
+ return "application/apply-patch+yaml"
87
+ }
88
+
89
+ // Data implements Patch.
90
+ func (p applyPatch ) Data (obj runtime.Object ) ([]byte , error ) {
91
+ // NB(directxman12): we might techically want to be using an actual encoder
92
+ // here (in case some more performant encoder is introduced) but this is
93
+ // correct and sufficient for our uses (it's what the JSON serializer in
94
+ // client-go does, more-or-less).
95
+ return json .Marshal (obj )
96
+ }
You can’t perform that action at this time.
0 commit comments