diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d73a71d2..71f055c4e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ - Added support for Postgres Kong config diagnostics and improved DB-less format. [#334](https://github.com/Kong/kubernetes-testing-framework/pull/334) +- The cleaner now has an `AddManifest()` function, to clean raw YAML manifests. + [#334](https://github.com/Kong/kubernetes-testing-framework/pull/334) ## v0.17.0 diff --git a/pkg/clusters/cleanup.go b/pkg/clusters/cleanup.go index e793ec7e1..c83b334d6 100644 --- a/pkg/clusters/cleanup.go +++ b/pkg/clusters/cleanup.go @@ -24,6 +24,7 @@ import ( type Cleaner struct { cluster Cluster objects []client.Object + manifests []string namespaces []*corev1.Namespace } @@ -40,6 +41,10 @@ func (c *Cleaner) Add(obj client.Object) { c.objects = append([]client.Object{obj}, c.objects...) } +func (c *Cleaner) AddManifest(manifest string) { + c.manifests = append(c.manifests, manifest) +} + func (c *Cleaner) AddNamespace(namespace *corev1.Namespace) { c.namespaces = append(c.namespaces, namespace) } @@ -201,6 +206,10 @@ func (c *Cleaner) Cleanup(ctx context.Context) error { } } + for _, manifest := range c.manifests { + DeleteManifestByYAML(ctx, c.cluster, manifest) + } + for _, namespace := range c.namespaces { if err := c.cluster.Client().CoreV1().Namespaces().Delete(ctx, namespace.Name, metav1.DeleteOptions{}); err != nil { return err