@@ -20,8 +20,6 @@ import (
2020
2121	"emperror.dev/errors" 
2222	json "github.com/json-iterator/go" 
23- 	v1 "k8s.io/api/apps/v1" 
24- 	corev1 "k8s.io/api/core/v1" 
2523	"k8s.io/apimachinery/pkg/util/intstr" 
2624)
2725
@@ -191,21 +189,31 @@ func deleteStatusField(obj []byte) ([]byte, error) {
191189}
192190
193191func  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 )
196194	if  err  !=  nil  {
197195		return  []byte {}, errors .Wrap (err , "could not unmarshal byte sequence" )
198196	}
199197
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+ 			}
205213		}
206214	}
207215
208- 	obj , err  =  json .ConfigCompatibleWithStandardLibrary .Marshal (sts )
216+ 	obj , err  =  json .ConfigCompatibleWithStandardLibrary .Marshal (resource )
209217	if  err  !=  nil  {
210218		return  []byte {}, errors .Wrap (err , "could not marshal byte sequence" )
211219	}
0 commit comments