-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.go
29 lines (24 loc) · 815 Bytes
/
deploy.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package monitoring
import (
"github.com/pkg/errors"
projectv3 "github.com/rancher/types/apis/project.cattle.io/v3"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
func WithdrawApp(cattleAppClient projectv3.AppInterface, appLabels metav1.ListOptions) error {
monitoringApps, err := cattleAppClient.List(appLabels)
if err != nil {
if k8serrors.IsNotFound(err) {
return nil
}
return errors.Wrapf(err, "failed to find App with %s", appLabels.String())
}
for _, app := range monitoringApps.Items {
if app.DeletionTimestamp == nil {
if err := cattleAppClient.DeleteNamespaced(app.Namespace, app.Name, &metav1.DeleteOptions{}); err != nil {
return errors.Wrapf(err, "failed to remove App with %s", appLabels.String())
}
}
}
return nil
}