Skip to content

Commit

Permalink
Clean up ResourceGroup with sync del (#3072)
Browse files Browse the repository at this point in the history
  • Loading branch information
mortent authored May 6, 2022
1 parent df9d9c7 commit 6694eb4
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions internal/cmdsync/delete/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,8 @@ func (r *runner) runE(cmd *cobra.Command, args []string) error {
Namespace: namespace,
Name: name,
}
rs := unstructured.Unstructured{
Object: map[string]interface{}{
"apiVersion": rootSyncGVK.GroupVersion().String(),
"kind": rootSyncGVK.Kind,
},
}
rs := unstructured.Unstructured{}
rs.SetGroupVersionKind(rootSyncGVK)
if err := r.client.Get(r.ctx, key, &rs); err != nil {
return errors.E(op, fmt.Errorf("cannot get %s: %v", key, err))
}
Expand Down Expand Up @@ -182,7 +178,15 @@ func (r *runner) runE(cmd *cobra.Command, args []string) error {
}

if err := r.client.Delete(r.ctx, &rs); err != nil {
return errors.E(op, err)
return errors.E(op, fmt.Errorf("failed to clean up RootSync: %w", err))
}

rg := unstructured.Unstructured{}
rg.SetGroupVersionKind(resourceGroupGVK)
rg.SetName(rs.GetName())
rg.SetNamespace(rs.GetNamespace())
if err := r.client.Delete(r.ctx, &rg); err != nil {
return errors.E(op, fmt.Errorf("failed to clean up ResourceGroup: %w", err))
}

if r.keepSecret {
Expand Down

0 comments on commit 6694eb4

Please sign in to comment.