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, )
| 80 | // cleanupNamespace does cleanup duty related to the tear-down of a namespace, |
| 81 | // and is intended to be called in a DeferCleanup clause |
| 82 | func 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 |
no test coverage detected