EnsureNamespace checks for the presence of a namespace, and if it does not exist, creates it
( ctx context.Context, crudClient client.Client, namespace string, )
| 155 | // EnsureNamespace checks for the presence of a namespace, and if it does not |
| 156 | // exist, creates it |
| 157 | func 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 |
| 176 | func deleteNamespace( |
no test coverage detected