@@ -132,12 +132,8 @@ func (r *runner) runE(cmd *cobra.Command, args []string) error {
132
132
Namespace : namespace ,
133
133
Name : name ,
134
134
}
135
- rs := unstructured.Unstructured {
136
- Object : map [string ]interface {}{
137
- "apiVersion" : rootSyncGVK .GroupVersion ().String (),
138
- "kind" : rootSyncGVK .Kind ,
139
- },
140
- }
135
+ rs := unstructured.Unstructured {}
136
+ rs .SetGroupVersionKind (rootSyncGVK )
141
137
if err := r .client .Get (r .ctx , key , & rs ); err != nil {
142
138
return errors .E (op , fmt .Errorf ("cannot get %s: %v" , key , err ))
143
139
}
@@ -182,7 +178,15 @@ func (r *runner) runE(cmd *cobra.Command, args []string) error {
182
178
}
183
179
184
180
if err := r .client .Delete (r .ctx , & rs ); err != nil {
185
- return errors .E (op , err )
181
+ return errors .E (op , fmt .Errorf ("failed to clean up RootSync: %w" , err ))
182
+ }
183
+
184
+ rg := unstructured.Unstructured {}
185
+ rg .SetGroupVersionKind (resourceGroupGVK )
186
+ rg .SetName (rs .GetName ())
187
+ rg .SetNamespace (rs .GetNamespace ())
188
+ if err := r .client .Delete (r .ctx , & rg ); err != nil {
189
+ return errors .E (op , fmt .Errorf ("failed to clean up ResourceGroup: %w" , err ))
186
190
}
187
191
188
192
if r .keepSecret {
0 commit comments