@@ -19,7 +19,91 @@ const (
19
19
OperatorConfigCRDResourceShort = "opconfig"
20
20
)
21
21
22
- func buildCRD (name , kind , plural , short string ) * apiextv1beta1.CustomResourceDefinition {
22
+ // PostgresCRDResourceColumns definition of AdditionalPrinterColumns for postgresql CRD
23
+ var PostgresCRDResourceColumns = []apiextv1beta1.CustomResourceColumnDefinition {
24
+ apiextv1beta1.CustomResourceColumnDefinition {
25
+ Name : "Team" ,
26
+ Type : "string" ,
27
+ Description : "Team responsible for Postgres cluster" ,
28
+ JSONPath : ".spec.teamId" ,
29
+ },
30
+ apiextv1beta1.CustomResourceColumnDefinition {
31
+ Name : "Version" ,
32
+ Type : "string" ,
33
+ Description : "PostgreSQL version" ,
34
+ JSONPath : ".spec.postgresql.version" ,
35
+ },
36
+ apiextv1beta1.CustomResourceColumnDefinition {
37
+ Name : "Pods" ,
38
+ Type : "integer" ,
39
+ Description : "Number of Pods per Postgres cluster" ,
40
+ JSONPath : ".spec.numberOfInstances" ,
41
+ },
42
+ apiextv1beta1.CustomResourceColumnDefinition {
43
+ Name : "Volume" ,
44
+ Type : "string" ,
45
+ Description : "Size of the bound volume" ,
46
+ JSONPath : ".spec.volume.size" ,
47
+ },
48
+ apiextv1beta1.CustomResourceColumnDefinition {
49
+ Name : "CPU-Request" ,
50
+ Type : "string" ,
51
+ Description : "Requested CPU for Postgres containers" ,
52
+ JSONPath : ".spec.resources.requests.cpu" ,
53
+ },
54
+ apiextv1beta1.CustomResourceColumnDefinition {
55
+ Name : "Memory-Request" ,
56
+ Type : "string" ,
57
+ Description : "Requested memory for Postgres containers" ,
58
+ JSONPath : ".spec.resources.requests.memory" ,
59
+ },
60
+ apiextv1beta1.CustomResourceColumnDefinition {
61
+ Name : "Age" ,
62
+ Type : "date" ,
63
+ JSONPath : ".metadata.creationTimestamp" ,
64
+ },
65
+ apiextv1beta1.CustomResourceColumnDefinition {
66
+ Name : "Status" ,
67
+ Type : "string" ,
68
+ Description : "Current sync status of postgresql resource" ,
69
+ JSONPath : ".status.PostgresClusterStatus" ,
70
+ },
71
+ }
72
+
73
+ // OperatorConfigCRDResourceColumns definition of AdditionalPrinterColumns for OperatorConfiguration CRD
74
+ var OperatorConfigCRDResourceColumns = []apiextv1beta1.CustomResourceColumnDefinition {
75
+ apiextv1beta1.CustomResourceColumnDefinition {
76
+ Name : "Image" ,
77
+ Type : "string" ,
78
+ Description : "Spilo image to be used for Pods" ,
79
+ JSONPath : ".configuration.docker_image" ,
80
+ },
81
+ apiextv1beta1.CustomResourceColumnDefinition {
82
+ Name : "Cluster-Label" ,
83
+ Type : "string" ,
84
+ Description : "Label for K8s resources created by operator" ,
85
+ JSONPath : ".configuration.kubernetes.cluster_name_label" ,
86
+ },
87
+ apiextv1beta1.CustomResourceColumnDefinition {
88
+ Name : "Service-Account" ,
89
+ Type : "string" ,
90
+ Description : "Name of service account to be used" ,
91
+ JSONPath : ".configuration.kubernetes.pod_service_account_name" ,
92
+ },
93
+ apiextv1beta1.CustomResourceColumnDefinition {
94
+ Name : "Min-Instances" ,
95
+ Type : "integer" ,
96
+ Description : "Minimum number of instances per Postgres cluster" ,
97
+ JSONPath : ".configuration.min_instances" ,
98
+ },
99
+ apiextv1beta1.CustomResourceColumnDefinition {
100
+ Name : "Age" ,
101
+ Type : "date" ,
102
+ JSONPath : ".metadata.creationTimestamp" ,
103
+ },
104
+ }
105
+
106
+ func buildCRD (name , kind , plural , short string , columns []apiextv1beta1.CustomResourceColumnDefinition ) * apiextv1beta1.CustomResourceDefinition {
23
107
return & apiextv1beta1.CustomResourceDefinition {
24
108
ObjectMeta : metav1.ObjectMeta {
25
109
Name : name ,
@@ -36,6 +120,7 @@ func buildCRD(name, kind, plural, short string) *apiextv1beta1.CustomResourceDef
36
120
Subresources : & apiextv1beta1.CustomResourceSubresources {
37
121
Status : & apiextv1beta1.CustomResourceSubresourceStatus {},
38
122
},
123
+ AdditionalPrinterColumns : columns ,
39
124
},
40
125
}
41
126
}
@@ -45,13 +130,15 @@ func PostgresCRD() *apiextv1beta1.CustomResourceDefinition {
45
130
return buildCRD (PostgresCRDResouceName ,
46
131
PostgresCRDResourceKind ,
47
132
PostgresCRDResourcePlural ,
48
- PostgresCRDResourceShort )
133
+ PostgresCRDResourceShort ,
134
+ PostgresCRDResourceColumns )
49
135
}
50
136
51
137
// ConfigurationCRD returns CustomResourceDefinition built from OperatorConfigCRDResource
52
138
func ConfigurationCRD () * apiextv1beta1.CustomResourceDefinition {
53
139
return buildCRD (OperatorConfigCRDResourceName ,
54
140
OperatorConfigCRDResouceKind ,
55
141
OperatorConfigCRDResourcePlural ,
56
- OperatorConfigCRDResourceShort )
142
+ OperatorConfigCRDResourceShort ,
143
+ OperatorConfigCRDResourceColumns )
57
144
}
0 commit comments