(ctx context.Context, objs ...client.Object)
| 159 | } |
| 160 | |
| 161 | func (c Client) DoDelete(ctx context.Context, objs ...client.Object) error { |
| 162 | for _, obj := range objs { |
| 163 | kind := obj.GetObjectKind().GroupVersionKind().Kind |
| 164 | log.Infof(" Deleting %s %q", kind, getName(obj.GetNamespace(), obj.GetName())) |
| 165 | err := c.KubeClient.Delete(ctx, obj, client.PropagationPolicy(metav1.DeletePropagationBackground)) |
| 166 | if err != nil { |
| 167 | if !apierrors.IsNotFound(err) { |
| 168 | return err |
| 169 | } |
| 170 | log.Infof(" %s %q does not exist", kind, getName(obj.GetNamespace(), obj.GetName())) |
| 171 | } |
| 172 | key := client.ObjectKeyFromObject(obj) |
| 173 | if err := wait.PollUntilContextCancel(ctx, time.Millisecond*100, false, func(pctx context.Context) (bool, error) { |
| 174 | err := c.KubeClient.Get(pctx, key, obj) |
| 175 | if apierrors.IsNotFound(err) { |
| 176 | return true, nil |
| 177 | } else if err != nil { |
| 178 | return false, err |
| 179 | } |
| 180 | return false, nil |
| 181 | }); err != nil { |
| 182 | return err |
| 183 | } |
| 184 | } |
| 185 | return nil |
| 186 | } |
| 187 | |
| 188 | func getName(namespace, name string) string { |
| 189 | if namespace != "" { |
no test coverage detected