@@ -20,8 +20,6 @@ import (
20
20
21
21
"emperror.dev/errors"
22
22
json "github.com/json-iterator/go"
23
- v1 "k8s.io/api/apps/v1"
24
- corev1 "k8s.io/api/core/v1"
25
23
"k8s.io/apimachinery/pkg/util/intstr"
26
24
)
27
25
@@ -191,21 +189,31 @@ func deleteStatusField(obj []byte) ([]byte, error) {
191
189
}
192
190
193
191
func deleteVolumeClaimTemplateFields (obj []byte ) ([]byte , error ) {
194
- sts := v1. StatefulSet {}
195
- err := json .Unmarshal (obj , & sts )
192
+ resource := map [ string ] interface {} {}
193
+ err := json .Unmarshal (obj , & resource )
196
194
if err != nil {
197
195
return []byte {}, errors .Wrap (err , "could not unmarshal byte sequence" )
198
196
}
199
197
200
- for i := range sts .Spec .VolumeClaimTemplates {
201
- sts .Spec .VolumeClaimTemplates [i ].Kind = ""
202
- sts .Spec .VolumeClaimTemplates [i ].APIVersion = ""
203
- sts .Spec .VolumeClaimTemplates [i ].Status = corev1.PersistentVolumeClaimStatus {
204
- Phase : corev1 .ClaimPending ,
198
+ if spec , ok := resource ["spec" ]; ok {
199
+ if spec , ok := spec .(map [string ]interface {}); ok {
200
+ if vcts , ok := spec ["volumeClaimTemplates" ]; ok {
201
+ if vcts , ok := vcts .([]interface {}); ok {
202
+ for _ , vct := range vcts {
203
+ if vct , ok := vct .(map [string ]interface {}); ok {
204
+ vct ["kind" ] = ""
205
+ vct ["apiVersion" ] = ""
206
+ vct ["status" ] = map [string ]string {
207
+ "phase" : "Pending" ,
208
+ }
209
+ }
210
+ }
211
+ }
212
+ }
205
213
}
206
214
}
207
215
208
- obj , err = json .ConfigCompatibleWithStandardLibrary .Marshal (sts )
216
+ obj , err = json .ConfigCompatibleWithStandardLibrary .Marshal (resource )
209
217
if err != nil {
210
218
return []byte {}, errors .Wrap (err , "could not marshal byte sequence" )
211
219
}
0 commit comments