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

Function CreateNamespace

tests/utils/namespaces/namespace.go:133–153  ·  view source on GitHub ↗

CreateNamespace creates a namespace.

(
	ctx context.Context,
	crudClient client.Client,
	name string,
	opts ...client.CreateOption,
)

Source from the content-addressed store, hash-verified

131
132// CreateNamespace creates a namespace.
133func CreateNamespace(
134 ctx context.Context,
135 crudClient client.Client,
136 name string,
137 opts ...client.CreateOption,
138) error {
139 // Exit immediately if the name is empty
140 if name == "" {
141 return errors.New("cannot create namespace with empty name")
142 }
143
144 u := &unstructured.Unstructured{}
145 u.SetName(name)
146 u.SetGroupVersionKind(schema.GroupVersionKind{
147 Group: "",
148 Version: "v1",
149 Kind: "Namespace",
150 })
151 _, err := objects.Create(ctx, crudClient, u, opts...)
152 return err
153}
154
155// EnsureNamespace checks for the presence of a namespace, and if it does not
156// exist, creates it

Calls 1

CreateFunction · 0.92

Tested by

no test coverage detected