-
Notifications
You must be signed in to change notification settings - Fork 39
/
gvr.go
50 lines (42 loc) · 1.35 KB
/
gvr.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
45
46
47
48
49
50
package utils
import (
"k8s.io/apimachinery/pkg/runtime/schema"
)
var AddOnDeploymentConfigGVR = schema.GroupVersionResource{
Group: "addon.open-cluster-management.io",
Version: "v1alpha1",
Resource: "addondeploymentconfigs",
}
var AddOnTemplateGVR = schema.GroupVersionResource{
Group: "addon.open-cluster-management.io",
Version: "v1alpha1",
Resource: "addontemplates",
}
var BuiltInAddOnConfigGVRs = map[schema.GroupVersionResource]bool{
AddOnDeploymentConfigGVR: true,
AddOnTemplateGVR: true,
}
// ContainGR returns true if the given group resource is in the given map
func ContainGR(gvrs map[schema.GroupVersionResource]bool, group, resource string) bool {
for gvr := range gvrs {
if gvr.Group == group && gvr.Resource == resource {
return true
}
}
return false
}
// FilterOutTheBuiltInAddOnConfigGVRs returns a new slice of GroupVersionResource that does not contain
// the built-in addOn config GVRs
func FilterOutTheBuiltInAddOnConfigGVRs(
gvrs map[schema.GroupVersionResource]bool) map[schema.GroupVersionResource]bool {
newGVRs := make(map[schema.GroupVersionResource]bool)
for gvr := range gvrs {
if !isBuiltInAddOnConfigGVR(gvr.Group, gvr.Resource) {
newGVRs[gvr] = true
}
}
return newGVRs
}
func isBuiltInAddOnConfigGVR(group, resource string) bool {
return ContainGR(BuiltInAddOnConfigGVRs, group, resource)
}