Skip to content

Commit 6d334d8

Browse files
committed
Make generated CRDs directly available for testing and development
Signed-off-by: Erik Godding Boye <[email protected]>
1 parent 67e71b6 commit 6d334d8

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
_bin
1+
_bin
2+
.idea/
3+
*.iml

modules/helm/crds.mk

+8-7
Original file line numberDiff line numberDiff line change
@@ -37,29 +37,30 @@ ifeq ($(HOST_OS),darwin)
3737
sed_inplace := sed -i ''
3838
endif
3939

40+
crds_dir ?= deboy/crds
41+
4042
.PHONY: generate-crds
4143
## Generate CRD manifests.
4244
## @category [shared] Generate/ Verify
4345
generate-crds: | $(NEEDS_CONTROLLER-GEN) $(NEEDS_YQ)
44-
$(eval crds_gen_temp := $(bin_dir)/scratch/crds)
4546
$(eval directories := $(shell ls -d */ | grep -v -e 'make' $(shell git check-ignore -- * | sed 's/^/-e /')))
4647

47-
rm -rf $(crds_gen_temp)
48-
mkdir -p $(crds_gen_temp)
48+
mkdir -p $(crds_dir)
49+
cp -r $(MAKEFILE_LIST)))/crds_dir.README.md $(crds_dir)/README.md
4950

5051
$(CONTROLLER-GEN) crd \
5152
$(directories:%=paths=./%...) \
52-
output:crd:artifacts:config=$(crds_gen_temp)
53+
output:crd:artifacts:config=$(crds_dir)
5354

5455
echo "Updating CRDs with helm templating, writing to $(helm_chart_source_dir)/templates"
5556

56-
@for i in $$(ls $(crds_gen_temp)); do \
57-
crd_name=$$($(YQ) eval '.metadata.name' $(crds_gen_temp)/$$i); \
57+
@for i in $$(ls $(crds_dir)); do \
58+
crd_name=$$($(YQ) eval '.metadata.name' $(crds_dir)/$$i); \
5859
cat $(crd_template_header) > $(helm_chart_source_dir)/templates/crd-$$i; \
5960
echo "" >> $(helm_chart_source_dir)/templates/crd-$$i; \
6061
$(sed_inplace) "s/REPLACE_CRD_NAME/$$crd_name/g" $(helm_chart_source_dir)/templates/crd-$$i; \
6162
$(sed_inplace) "s/REPLACE_LABELS_TEMPLATE/$(helm_labels_template_name)/g" $(helm_chart_source_dir)/templates/crd-$$i; \
62-
$(YQ) -I2 '{"spec": .spec}' $(crds_gen_temp)/$$i >> $(helm_chart_source_dir)/templates/crd-$$i; \
63+
$(YQ) -I2 '{"spec": .spec}' $(crds_dir)/$$i >> $(helm_chart_source_dir)/templates/crd-$$i; \
6364
cat $(crd_template_footer) >> $(helm_chart_source_dir)/templates/crd-$$i; \
6465
done
6566

modules/helm/crds_dir.README.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# CRDs source directory
2+
3+
> **WARNING**: if you are an end-user, you probably should NOT need to use the
4+
> files in this directory. These files are for **reference, development and testing purposes only**.
5+
6+
This directory contains 'source code' used to build our CustomResourceDefinition
7+
resources consumed by our officially supported deployment methods (e.g. the Helm chart).
8+
The CRDs in this directory might be incomplete, and should **NOT** be used to provision the operator.

0 commit comments

Comments
 (0)