MCPcopy Create free account
hub / github.com/cloudnative-pg/cloudnative-pg / EnsureNamespace

Function EnsureNamespace

tests/utils/namespaces/namespace.go:157–173  ·  view source on GitHub ↗

EnsureNamespace checks for the presence of a namespace, and if it does not exist, creates it

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

Source from the content-addressed store, hash-verified

155// EnsureNamespace checks for the presence of a namespace, and if it does not
156// exist, creates it
157func EnsureNamespace(
158 ctx context.Context,
159 crudClient client.Client,
160 namespace string,
161) error {
162 var nsList corev1.NamespaceList
163 err := objects.List(ctx, crudClient, &nsList)
164 if err != nil {
165 return err
166 }
167 for _, ns := range nsList.Items {
168 if ns.Name == namespace {
169 return nil
170 }
171 }
172 return CreateNamespace(ctx, crudClient, namespace)
173}
174
175// deleteNamespace deletes a namespace if existent
176func deleteNamespace(

Callers 1

upgrade_test.goFile · 0.92

Calls 2

ListFunction · 0.92
CreateNamespaceFunction · 0.85

Tested by

no test coverage detected