Skip to content

Commit 6694eb4

Browse files
authored
Clean up ResourceGroup with sync del (#3072)
1 parent df9d9c7 commit 6694eb4

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

internal/cmdsync/delete/command.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,8 @@ func (r *runner) runE(cmd *cobra.Command, args []string) error {
132132
Namespace: namespace,
133133
Name: name,
134134
}
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)
141137
if err := r.client.Get(r.ctx, key, &rs); err != nil {
142138
return errors.E(op, fmt.Errorf("cannot get %s: %v", key, err))
143139
}
@@ -182,7 +178,15 @@ func (r *runner) runE(cmd *cobra.Command, args []string) error {
182178
}
183179

184180
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))
186190
}
187191

188192
if r.keepSecret {

0 commit comments

Comments
 (0)