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

Function cleanupNamespace

tests/utils/namespaces/namespace.go:82–101  ·  view source on GitHub ↗

cleanupNamespace does cleanup duty related to the tear-down of a namespace, and is intended to be called in a DeferCleanup clause

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

Source from the content-addressed store, hash-verified

80// cleanupNamespace does cleanup duty related to the tear-down of a namespace,
81// and is intended to be called in a DeferCleanup clause
82func cleanupNamespace(
83 ctx context.Context,
84 crudClient client.Client,
85 namespace, testName string,
86 testFailed bool,
87) error {
88 if testFailed {
89 DumpNamespaceObjects(ctx, crudClient, namespace, "out/"+testName+".log")
90 }
91
92 if len(namespace) == 0 {
93 return fmt.Errorf("namespace is empty")
94 }
95
96 if err := CleanupClusterLogs(namespace, testFailed); err != nil {
97 return err
98 }
99
100 return deleteNamespace(ctx, crudClient, namespace)
101}
102
103// CreateTestNamespace creates a namespace creates a namespace.
104// Prefer CreateUniqueTestNamespace instead, unless you need a

Callers 1

CreateTestNamespaceFunction · 0.85

Calls 3

DumpNamespaceObjectsFunction · 0.85
CleanupClusterLogsFunction · 0.85
deleteNamespaceFunction · 0.85

Tested by

no test coverage detected