ensureNamespace installs namespace of a given name if not exists.
(ctx context.Context, namespace string, client client.Client)
| 2604 | |
| 2605 | // ensureNamespace installs namespace of a given name if not exists. |
| 2606 | func ensureNamespace(ctx context.Context, namespace string, client client.Client) error { |
| 2607 | ns := corev1.Namespace{ |
| 2608 | ObjectMeta: metav1.ObjectMeta{ |
| 2609 | Name: namespace, |
| 2610 | }, |
| 2611 | TypeMeta: metav1.TypeMeta{ |
| 2612 | Kind: "Namespace", |
| 2613 | APIVersion: "v1", |
| 2614 | }, |
| 2615 | } |
| 2616 | err := client.Create(ctx, &ns) |
| 2617 | if apierrors.IsAlreadyExists(err) { |
| 2618 | return nil |
| 2619 | } |
| 2620 | return err |
| 2621 | } |
| 2622 | |
| 2623 | func ensureNode(ctx context.Context, name string, client client.Client) error { |
| 2624 | node := corev1.Node{ |
no test coverage detected
searching dependent graphs…