-
Notifications
You must be signed in to change notification settings - Fork 19
/
types.go
58 lines (52 loc) · 1.7 KB
/
types.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
package manifests
import (
appsv1 "k8s.io/api/apps/v1"
autov1 "k8s.io/api/autoscaling/v1"
corev1 "k8s.io/api/core/v1"
netv1 "k8s.io/api/networking/v1"
policyv1 "k8s.io/api/policy/v1"
rbacv1 "k8s.io/api/rbac/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
)
// resourceType is a struct that represents a Kubernetes resource type
type resourceType struct {
Group string
Version string
// Name is the name of the resource type
Name string
}
// NginxResources is a struct that represents the Kubernetes resources that are created for the Nginx Ingress Controller. When these resources
// are acted upon by client-go, the fields here are updated since they are pointers to the actual resources.
type NginxResources struct {
Namespace *corev1.Namespace
IngressClass *netv1.IngressClass
ServiceAccount *corev1.ServiceAccount
ClusterRole *rbacv1.ClusterRole
Role *rbacv1.Role
ClusterRoleBinding *rbacv1.ClusterRoleBinding
RoleBinding *rbacv1.RoleBinding
Service *corev1.Service
Deployment *appsv1.Deployment
ConfigMap *corev1.ConfigMap
HorizontalPodAutoscaler *autov1.HorizontalPodAutoscaler
PodDisruptionBudget *policyv1.PodDisruptionBudget
}
func (n *NginxResources) Objects() []client.Object {
objs := []client.Object{
n.IngressClass,
n.ServiceAccount,
n.ClusterRole,
n.Role,
n.ClusterRoleBinding,
n.RoleBinding,
n.Service,
n.Deployment,
n.ConfigMap,
n.HorizontalPodAutoscaler,
n.PodDisruptionBudget,
}
if n.Namespace != nil {
objs = append([]client.Object{n.Namespace}, objs...) // put namespace at front, so we can create resources in order
}
return objs
}