Skip to content

Commit

Permalink
feat: add manifest deleter to cleaner
Browse files Browse the repository at this point in the history
  • Loading branch information
rainest committed Jul 29, 2022
1 parent 20eea10 commit 871f7f7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 9 additions & 0 deletions pkg/clusters/cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
type Cleaner struct {
cluster Cluster
objects []client.Object
manifests []string
namespaces []*corev1.Namespace
}

Expand All @@ -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)
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 871f7f7

Please sign in to comment.