File tree Expand file tree Collapse file tree 1 file changed +48
-1
lines changed Expand file tree Collapse file tree 1 file changed +48
-1
lines changed Original file line number Diff line number Diff line change @@ -118,6 +118,53 @@ function generate_crd_resources {
118
118
# Run the commands
119
119
kubebuilder init repo --domain sample.kubernetes.io
120
120
kubebuilder create resource --group insect --version v1beta1 --kind Bee
121
+
122
+ header_text " generating CRD definition"
123
+ kubebuilder create config --crds --output crd.yaml
124
+
125
+ # Test for the expected generated CRD definition
126
+ #
127
+ # TODO: this is awkwardly inserted after the first resource created in this
128
+ # test because the output order seems nondeterministic and it's preferable to
129
+ # avoid introducing a new dependency like yq or complex parsing logic
130
+ cat << EOF > expected.yaml
131
+ apiVersion: apiextensions.k8s.io/v1beta1
132
+ kind: CustomResourceDefinition
133
+ metadata:
134
+ creationTimestamp: null
135
+ labels:
136
+ api: ""
137
+ kubebuilder.k8s.io: unknown
138
+ name: bees.insect.sample.kubernetes.io
139
+ spec:
140
+ group: insect.sample.kubernetes.io
141
+ names:
142
+ kind: Bee
143
+ plural: bees
144
+ scope: Namespaced
145
+ validation:
146
+ openAPIV3Schema:
147
+ properties:
148
+ apiVersion:
149
+ type: string
150
+ kind:
151
+ type: string
152
+ metadata:
153
+ type: object
154
+ spec:
155
+ type: object
156
+ status:
157
+ type: object
158
+ type: object
159
+ version: v1beta1
160
+ status:
161
+ acceptedNames:
162
+ kind: ""
163
+ plural: ""
164
+ conditions: null
165
+ EOF
166
+ diff crd.yaml expected.yaml
167
+
121
168
kubebuilder create resource --group insect --version v1beta1 --kind Wasp
122
169
}
123
170
@@ -137,7 +184,7 @@ fetch_tools
137
184
build_kb
138
185
prepare_vendor_deps
139
186
prepare_testdir_under_gopath
187
+
140
188
generate_crd_resources
141
189
test_generated_controller
142
-
143
190
exit $rc
You can’t perform that action at this time.
0 commit comments