Skip to content

Commit

Permalink
Add basic test for kubebuilder create config --crds
Browse files Browse the repository at this point in the history
  • Loading branch information
pmorie committed May 2, 2018
1 parent 044dc0f commit 7960de2
Showing 1 changed file with 48 additions and 1 deletion.
49 changes: 48 additions & 1 deletion test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -137,7 +184,7 @@ fetch_tools
build_kb
prepare_vendor_deps
prepare_testdir_under_gopath

generate_crd_resources
test_generated_controller

exit $rc

0 comments on commit 7960de2

Please sign in to comment.