-
Notifications
You must be signed in to change notification settings - Fork 128
/
utils.go
44 lines (40 loc) · 999 Bytes
/
utils.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package main
import (
"context"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/rest"
)
func argoCDExists(
ctx context.Context,
restCfg *rest.Config,
namespace string,
) bool {
if client, err := dynamic.NewForConfig(restCfg); err == nil {
if _, err = client.Resource(
schema.GroupVersionResource{
Group: "argoproj.io",
Version: "v1alpha1",
Resource: "applications",
},
).Namespace(namespace).List(ctx, metav1.ListOptions{Limit: 1}); err == nil {
return true
}
}
return false
}
func argoRolloutsExists(ctx context.Context, restCfg *rest.Config) bool {
if client, err := dynamic.NewForConfig(restCfg); err == nil {
if _, err = client.Resource(
schema.GroupVersionResource{
Group: "argoproj.io",
Version: "v1alpha1",
Resource: "analysistemplates",
},
).List(ctx, metav1.ListOptions{Limit: 1}); err == nil {
return true
}
}
return false
}