@@ -18,12 +18,10 @@ var escapeJSONPointer = strings.NewReplacer(
1818 "/" , "~1" ,
1919).Replace
2020
21- // JSON6902 represents a JSON Patch according to RFC 6902; the same as
22- // k8s.io/apimachinery/pkg/types.JSONPatchType.
23- type JSON6902 []interface {}
21+ // JSON6902 represents a JSON Patch according to RFC 6902; the same as [types.JSONPatchType].
22+ type JSON6902 []any
2423
25- // NewJSONPatch creates a new JSON Patch according to RFC 6902; the same as
26- // k8s.io/apimachinery/pkg/types.JSONPatchType.
24+ // NewJSONPatch creates a new JSON Patch according to RFC 6902; the same as [types.JSONPatchType].
2725func NewJSONPatch () * JSON6902 { return & JSON6902 {} }
2826
2927func (* JSON6902 ) pointer (tokens ... string ) string {
@@ -50,10 +48,10 @@ func (*JSON6902) pointer(tokens ...string) string {
5048// >
5149// > o If the target location specifies an object member that does exist,
5250// > that member's value is replaced.
53- func (patch * JSON6902 ) Add (path ... string ) func (value interface {} ) * JSON6902 {
51+ func (patch * JSON6902 ) Add (path ... string ) func (value any ) * JSON6902 {
5452 i := len (* patch )
55- f := func (value interface {} ) * JSON6902 {
56- (* patch )[i ] = map [string ]interface {} {
53+ f := func (value any ) * JSON6902 {
54+ (* patch )[i ] = map [string ]any {
5755 "op" : "add" ,
5856 "path" : patch .pointer (path ... ),
5957 "value" : value ,
@@ -72,7 +70,7 @@ func (patch *JSON6902) Add(path ...string) func(value interface{}) *JSON6902 {
7270// >
7371// > The target location MUST exist for the operation to be successful.
7472func (patch * JSON6902 ) Remove (path ... string ) * JSON6902 {
75- * patch = append (* patch , map [string ]interface {} {
73+ * patch = append (* patch , map [string ]any {
7674 "op" : "remove" ,
7775 "path" : patch .pointer (path ... ),
7876 })
@@ -86,10 +84,10 @@ func (patch *JSON6902) Remove(path ...string) *JSON6902 {
8684// > with a new value.
8785// >
8886// > The target location MUST exist for the operation to be successful.
89- func (patch * JSON6902 ) Replace (path ... string ) func (value interface {} ) * JSON6902 {
87+ func (patch * JSON6902 ) Replace (path ... string ) func (value any ) * JSON6902 {
9088 i := len (* patch )
91- f := func (value interface {} ) * JSON6902 {
92- (* patch )[i ] = map [string ]interface {} {
89+ f := func (value any ) * JSON6902 {
90+ (* patch )[i ] = map [string ]any {
9391 "op" : "replace" ,
9492 "path" : patch .pointer (path ... ),
9593 "value" : value ,
@@ -103,23 +101,21 @@ func (patch *JSON6902) Replace(path ...string) func(value interface{}) *JSON6902
103101}
104102
105103// Bytes returns the JSON representation of patch.
106- func (patch JSON6902 ) Bytes () ([]byte , error ) { return patch .Data (nil ) }
104+ func (patch * JSON6902 ) Bytes () ([]byte , error ) { return patch .Data (nil ) }
107105
108106// Data returns the JSON representation of patch.
109- func (patch JSON6902 ) Data (client.Object ) ([]byte , error ) { return json .Marshal (patch ) }
107+ func (patch * JSON6902 ) Data (client.Object ) ([]byte , error ) { return json .Marshal (* patch ) }
110108
111109// IsEmpty returns true when patch has no operations.
112- func (patch JSON6902 ) IsEmpty () bool { return len (patch ) == 0 }
110+ func (patch * JSON6902 ) IsEmpty () bool { return len (* patch ) == 0 }
113111
114- // Type returns k8s.io/apimachinery/pkg/ types.JSONPatchType.
115- func (patch JSON6902 ) Type () types.PatchType { return types .JSONPatchType }
112+ // Type returns [ types.JSONPatchType] .
113+ func (patch * JSON6902 ) Type () types.PatchType { return types .JSONPatchType }
116114
117- // Merge7386 represents a JSON Merge Patch according to RFC 7386; the same as
118- // k8s.io/apimachinery/pkg/types.MergePatchType.
119- type Merge7386 map [string ]interface {}
115+ // Merge7386 represents a JSON Merge Patch according to RFC 7386; the same as [types.MergePatchType].
116+ type Merge7386 map [string ]any
120117
121- // NewMergePatch creates a new JSON Merge Patch according to RFC 7386; the same
122- // as k8s.io/apimachinery/pkg/types.MergePatchType.
118+ // NewMergePatch creates a new JSON Merge Patch according to RFC 7386; the same as [types.MergePatchType].
123119func NewMergePatch () * Merge7386 { return & Merge7386 {} }
124120
125121// Add modifies patch to indicate that the member at path should be added or
@@ -130,7 +126,7 @@ func NewMergePatch() *Merge7386 { return &Merge7386{} }
130126// > contain the member, the value is replaced. Null values in the merge
131127// > patch are given special meaning to indicate the removal of existing
132128// > values in the target.
133- func (patch * Merge7386 ) Add (path ... string ) func (value interface {} ) * Merge7386 {
129+ func (patch * Merge7386 ) Add (path ... string ) func (value any ) * Merge7386 {
134130 position := * patch
135131
136132 for len (path ) > 1 {
@@ -145,10 +141,10 @@ func (patch *Merge7386) Add(path ...string) func(value interface{}) *Merge7386 {
145141 }
146142
147143 if len (path ) < 1 {
148- return func (interface {} ) * Merge7386 { return patch }
144+ return func (any ) * Merge7386 { return patch }
149145 }
150146
151- f := func (value interface {} ) * Merge7386 {
147+ f := func (value any ) * Merge7386 {
152148 position [path [0 ]] = value
153149 return patch
154150 }
@@ -165,13 +161,13 @@ func (patch *Merge7386) Remove(path ...string) *Merge7386 {
165161}
166162
167163// Bytes returns the JSON representation of patch.
168- func (patch Merge7386 ) Bytes () ([]byte , error ) { return patch .Data (nil ) }
164+ func (patch * Merge7386 ) Bytes () ([]byte , error ) { return patch .Data (nil ) }
169165
170166// Data returns the JSON representation of patch.
171- func (patch Merge7386 ) Data (client.Object ) ([]byte , error ) { return json .Marshal (patch ) }
167+ func (patch * Merge7386 ) Data (client.Object ) ([]byte , error ) { return json .Marshal (* patch ) }
172168
173169// IsEmpty returns true when patch has no modifications.
174- func (patch Merge7386 ) IsEmpty () bool { return len (patch ) == 0 }
170+ func (patch * Merge7386 ) IsEmpty () bool { return len (* patch ) == 0 }
175171
176- // Type returns k8s.io/apimachinery/pkg/ types.MergePatchType.
177- func (patch Merge7386 ) Type () types.PatchType { return types .MergePatchType }
172+ // Type returns [ types.MergePatchType] .
173+ func (patch * Merge7386 ) Type () types.PatchType { return types .MergePatchType }
0 commit comments