-
Notifications
You must be signed in to change notification settings - Fork 30
/
map.go
139 lines (133 loc) · 5.78 KB
/
map.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
package kube
import (
"strings"
)
// APIVersions map of allowed K8s API VERSIONS
var APIVersions = map[string]bool{
"v1": true,
"v1beta1": true,
"v1beta2": true,
"v2beta1": true,
"v1alpha1": true,
}
// APIPkgMap maps K8s API Groups to their corresponding go packages
var APIPkgMap = map[string]string{
"admissionregistration.k8s.io": "k8s.io/api/admissionregistration",
"apiextensions.k8s.io": "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions",
"apiregistration.k8s.io": "k8s.io/kube-aggregator/pkg/apis/apiregistration",
"apps": "k8s.io/api/apps",
"authentication.k8s.io": "k8s.io/api/authentication",
"autoscaling": "k8s.io/api/autoscaling",
"batch": "k8s.io/api/batch",
"certificates.k8s.io": "k8s.io/api/certificates",
"coordination.k8s.io": "k8s.io/api/coordination",
"events.k8s.io": "k8s.io/api/events",
"networking.k8s.io": "k8s.io/api/networking",
"node.k8s.io": "k8s.io/api/node",
"policy": "k8s.io/api/policy",
"rbac.authorization.k8s.io": "k8s.io/api/rbac",
"scheduling.k8s.io": "k8s.io/api/scheduling",
"storage.k8s.io": "k8s.io/api/storage",
"corev1": "k8s.io/api/core",
"metav1": "k8s.io/apimachinery/pkg/apis/meta",
"intstr": "k8s.io/apimachinery/pkg/util/intstr",
"resource": "k8s.io/apimachinery/pkg/api/resource",
}
// KindAPIMap maps K8s Kinds to their respective API Groups
var KindAPIMap = map[string]string{
"MutatingWebhookConfiguration": "admissionregistration.k8s.io",
"ValidatingWebhookConfiguration": "admissionregistration.k8s.io",
"ServiceReference": "admissionregistration.k8s.io",
"CustomResourceDefinition": "apiextensions.k8s.io",
"APIService": "apiregistration.k8s.io",
"ControllerRevision": "apps",
"DaemonSet": "apps",
"Deployment": "apps",
"ReplicaSet": "apps",
"StatefulSet": "apps",
"TokenReview": "authentication.k8s.io",
"LocalSubjectAccessReview": "authorization.k8s.io",
"SelfSubjectAccessReview": "authorization.k8s.io",
"SelfSubjectRulesReview": "authorization.k8s.io",
"SubjectAccessReview": "authorization.k8s.io",
"HorizontalPodAutoscaler": "autoscaling",
"CronJob": "batch",
"Job": "batch",
"CertificateSigningRequest": "certificates.k8s.io",
"BackendConfig": "cloud.google.com",
"NodeMetrics": "metrics.k8s.io",
"PodMetrics": "metrics.k8s.io",
"ManagedCertificate": "networking.gke.io",
"NetworkPolicy": "networking.k8s.io",
"Ingress": "networking.k8s.io",
"PodDisruptionBudget": "policy",
"PodSecurityPolicy": "policy",
"ClusterRoleBinding": "rbac.authorization.k8s.io",
"ClusterRole": "rbac.authorization.k8s.io",
"RoleBinding": "rbac.authorization.k8s.io",
"Role": "rbac.authorization.k8s.io",
"ScalingPolicy": "scalingpolicy.kope.io",
"PriorityClass": "scheduling.k8s.io",
"StorageClass": "storage.k8s.io",
"VolumeAttachment": "storage.k8s.io",
"Binding": "corev1",
"ComponentStatus": "corev1",
"ConfigMap": "corev1",
"Endpoints": "corev1",
"Event": "corev1",
"LimitRange": "corev1",
"Namespace": "corev1",
"Node": "corev1",
"PersistentVolumeClaim": "corev1",
"PersistentVolume": "corev1",
"Pod": "corev1",
"PodTemplate": "corev1",
"ReplicationController": "corev1",
"ResourceQuota": "corev1",
"Secret": "corev1",
"ServiceAccount": "corev1",
"Service": "corev1",
"PersistentVolumeMode": "corev1",
"ResourceRequirements": "corev1",
"Protocol": "corev1",
"TypeMeta": "metav1",
"ObjectMeta": "metav1",
"LabelSelector": "metav1",
"Duration": "metav1",
}
// KindNamespaced keeps maps of Namespaced K8s resources
var KindNamespaced = map[string]bool{
"Binding": true,
"ConfigMap": true,
"Endpoints": true,
"Event": true,
"LimitRange": true,
"PersistentVolumeClaim": true,
"Pod": true,
"PodTemplate": true,
"ReplicationController": true,
"ResourceQuota": true,
"Secret": true,
"ServiceAccount": true,
"Service": true,
"ControllerRevision": true,
"DaemonSet": true,
"Deployment": true,
"ReplicaSet": true,
"StatefulSet": true,
"LocalSubjectAccessReview": true,
"HorizontalPodAutoscaler": true,
"CronJob": true,
"Job": true,
"Lease": true,
"Ingress": true,
"NetworkPolicy": true,
"PodDisruptionBudget": true,
"RoleBinding": true,
"Role": true,
}
// GenerateImportAs finds short name to import package as
func GenerateImportAs(pkg, version string) string {
p := strings.Split(pkg, "/")
return p[len(p)-1] + version
}