MCPcopy
hub / github.com/kubernetes-sigs/controller-runtime / ensureNamespace

Function ensureNamespace

pkg/cache/cache_test.go:2606–2621  ·  view source on GitHub ↗

ensureNamespace installs namespace of a given name if not exists.

(ctx context.Context, namespace string, client client.Client)

Source from the content-addressed store, hash-verified

2604
2605// ensureNamespace installs namespace of a given name if not exists.
2606func 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
2623func ensureNode(ctx context.Context, name string, client client.Client) error {
2624 node := corev1.Node{

Callers 3

cache_test.goFile · 0.85
NonBlockingGetTestFunction · 0.85
CacheTestFunction · 0.85

Calls 1

CreateMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…