diff --git a/.gitignore b/.gitignore index 4fd58eb..22f5395 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -_bin \ No newline at end of file +_bin +.idea/ +*.iml diff --git a/modules/helm/crds.mk b/modules/helm/crds.mk index bcc208b..2eefe69 100644 --- a/modules/helm/crds.mk +++ b/modules/helm/crds.mk @@ -37,29 +37,34 @@ ifeq ($(HOST_OS),darwin) sed_inplace := sed -i '' endif +crds_dir ?= deploy/crds +crds_dir_readme := $(dir $(lastword $(MAKEFILE_LIST)))/crds_dir.README.md + +$(crds_dir): + mkdir -p $@ + +$(crds_dir)/README.md: $(crds_dir_readme) | $(crds_dir) + cp $< $@ + .PHONY: generate-crds ## Generate CRD manifests. ## @category [shared] Generate/ Verify generate-crds: | $(NEEDS_CONTROLLER-GEN) $(NEEDS_YQ) - $(eval crds_gen_temp := $(bin_dir)/scratch/crds) $(eval directories := $(shell ls -d */ | grep -v -e 'make' $(shell git check-ignore -- * | sed 's/^/-e /'))) - rm -rf $(crds_gen_temp) - mkdir -p $(crds_gen_temp) - $(CONTROLLER-GEN) crd \ $(directories:%=paths=./%...) \ - output:crd:artifacts:config=$(crds_gen_temp) + output:crd:artifacts:config=$(crds_dir) echo "Updating CRDs with helm templating, writing to $(helm_chart_source_dir)/templates" - @for i in $$(ls $(crds_gen_temp)); do \ - crd_name=$$($(YQ) eval '.metadata.name' $(crds_gen_temp)/$$i); \ + @for i in $$(basename $(crds_dir)/*.yaml); do \ + crd_name=$$($(YQ) eval '.metadata.name' $(crds_dir)/$$i); \ cat $(crd_template_header) > $(helm_chart_source_dir)/templates/crd-$$i; \ echo "" >> $(helm_chart_source_dir)/templates/crd-$$i; \ $(sed_inplace) "s/REPLACE_CRD_NAME/$$crd_name/g" $(helm_chart_source_dir)/templates/crd-$$i; \ $(sed_inplace) "s/REPLACE_LABELS_TEMPLATE/$(helm_labels_template_name)/g" $(helm_chart_source_dir)/templates/crd-$$i; \ - $(YQ) -I2 '{"spec": .spec}' $(crds_gen_temp)/$$i >> $(helm_chart_source_dir)/templates/crd-$$i; \ + $(YQ) -I2 '{"spec": .spec}' $(crds_dir)/$$i >> $(helm_chart_source_dir)/templates/crd-$$i; \ cat $(crd_template_footer) >> $(helm_chart_source_dir)/templates/crd-$$i; \ done diff --git a/modules/helm/crds_dir.README.md b/modules/helm/crds_dir.README.md new file mode 100644 index 0000000..fba79fe --- /dev/null +++ b/modules/helm/crds_dir.README.md @@ -0,0 +1,8 @@ +# CRDs source directory + +> **WARNING**: if you are an end-user, you probably should NOT need to use the +> files in this directory. These files are for **reference, development and testing purposes only**. + +This directory contains 'source code' used to build our CustomResourceDefinition +resources consumed by our officially supported deployment methods (e.g. the Helm chart). +The CRDs in this directory might be incomplete, and should **NOT** be used to provision the operator. \ No newline at end of file