Skip to content

Commit

Permalink
feat: Delete the starboard namespace on issuing cleanup command (aqua…
Browse files Browse the repository at this point in the history
  • Loading branch information
krisctl authored Jul 9, 2020
1 parent 8042eac commit d43faef
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pkg/kube/cr_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package kube

import (
"context"

starboard "github.com/aquasecurity/starboard/pkg/apis/aquasecurity/v1alpha1"
core "k8s.io/api/core/v1"
rbac "k8s.io/api/rbac/v1"
Expand Down Expand Up @@ -307,6 +308,15 @@ func (m *crManager) cleanupPolaris(ctx context.Context) (err error) {
return nil
}

func (m *crManager) cleanupNamespace(ctx context.Context) (err error) {
klog.V(3).Infof("Deleting Namespace %s", NamespaceStarboard)
err = m.clientset.CoreV1().Namespaces().Delete(ctx, NamespaceStarboard, meta.DeleteOptions{})
if err != nil && !errors.IsNotFound(err) {
return
}
return nil
}

func (m *crManager) createNamespaceIfNotFound(ctx context.Context, name string) (err error) {
_, err = m.clientset.CoreV1().Namespaces().Get(ctx, name, meta.GetOptions{})
switch {
Expand Down Expand Up @@ -445,5 +455,9 @@ func (m *crManager) Cleanup(ctx context.Context) (err error) {
if err != nil {
return
}
err = m.cleanupNamespace(ctx)
if err != nil {
return
}
return
}

0 comments on commit d43faef

Please sign in to comment.