From 7960de25d6b97980bed2ba7e0328b2ab5936e14a Mon Sep 17 00:00:00 2001 From: Paul Morie Date: Wed, 2 May 2018 00:52:54 -0400 Subject: [PATCH] Add basic test for kubebuilder create config --crds --- test.sh | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/test.sh b/test.sh index 5c3582fbc9..7565e6a19a 100755 --- a/test.sh +++ b/test.sh @@ -118,6 +118,53 @@ function generate_crd_resources { # Run the commands kubebuilder init repo --domain sample.kubernetes.io kubebuilder create resource --group insect --version v1beta1 --kind Bee + + header_text "generating CRD definition" + kubebuilder create config --crds --output crd.yaml + + # Test for the expected generated CRD definition + # + # TODO: this is awkwardly inserted after the first resource created in this + # test because the output order seems nondeterministic and it's preferable to + # avoid introducing a new dependency like yq or complex parsing logic + cat << EOF > expected.yaml +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + creationTimestamp: null + labels: + api: "" + kubebuilder.k8s.io: unknown + name: bees.insect.sample.kubernetes.io +spec: + group: insect.sample.kubernetes.io + names: + kind: Bee + plural: bees + scope: Namespaced + validation: + openAPIV3Schema: + properties: + apiVersion: + type: string + kind: + type: string + metadata: + type: object + spec: + type: object + status: + type: object + type: object + version: v1beta1 +status: + acceptedNames: + kind: "" + plural: "" + conditions: null +EOF + diff crd.yaml expected.yaml + kubebuilder create resource --group insect --version v1beta1 --kind Wasp } @@ -137,7 +184,7 @@ fetch_tools build_kb prepare_vendor_deps prepare_testdir_under_gopath + generate_crd_resources test_generated_controller - exit $rc