github.com/verrazzano/verrazzano@v1.7.0/make/generate.mk (about) 1 # Copyright (C) 2020, 2023, Oracle and/or its affiliates. 2 # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 4 # Generate manifests e.g. CRD, RBAC etc. 5 .PHONY: platform-manifests 6 platform-manifests: controller-gen 7 $(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=$(CRD_PATH) 8 # Add copyright headers to the kubebuilder generated CRDs 9 ./hack/add-crd-header.sh 10 ./hack/update-codegen.sh "verrazzano:v1beta1,v1alpha1" "boilerplate.go.txt" 11 # The module CRD must be added to the VPO helm chart after code generation 12 ./hack/download_module_crd.sh 13 14 # Generate manifests e.g. CRD, RBAC etc. 15 .PHONY: application-manifests 16 application-manifests: controller-gen 17 $(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role paths="./apis/oam/..." output:crd:artifacts:config=$(CRD_PATH) 18 $(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role paths="./apis/app/..." output:crd:artifacts:config=$(CRD_PATH) 19 # Put multicluster CRDs in the cluster agent helm chart 20 $(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role paths="./apis/clusters/..." output:crd:artifacts:config=$(MC_CRD_PATH) 21 # Add copyright headers to the kubebuilder generated CRDs 22 ./hack/add-crd-header.sh 23 ./hack/update-codegen.sh "clusters:v1alpha1 oam:v1alpha1 app:v1alpha1" "boilerplate.go.txt" 24 # Add copyright headers to the kubebuilder generated manifests 25 ./hack/add-yml-header.sh PROJECT 26 27 # Generate manifests e.g. CRD, RBAC etc. for cluster operator 28 .PHONY: cluster-manifests 29 cluster-manifests: controller-gen 30 $(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./apis/..." output:crd:artifacts:config=$(CRD_PATH) 31 # Add copyright headers to the kubebuilder generated CRDs 32 ./hack/add-crd-header.sh 33 ./hack/update-codegen.sh "clusters:v1alpha1" "boilerplate.go.txt" 34 # Add copyright headers to the kubebuilder generated manifests 35 ./hack/add-yml-header.sh PROJECT 36 37 # Generate code 38 .PHONY: generate 39 generate: controller-gen 40 $(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..." 41 42 # find or download controller-gen 43 # download controller-gen if necessary 44 CONTROLLER_GEN_PATH := $(shell eval go env GOPATH) 45 .PHONY: controller-gen 46 controller-gen: 47 ifeq (, $(shell command -v controller-gen)) 48 $(GO) install sigs.k8s.io/controller-tools/cmd/controller-gen@${CONTROLLER_GEN_VERSION} 49 $(eval CONTROLLER_GEN=$(CONTROLLER_GEN_PATH)/bin/controller-gen) 50 else 51 $(eval CONTROLLER_GEN=$(shell command -v controller-gen)) 52 endif 53 @{ \ 54 set -eu; \ 55 ACTUAL_CONTROLLER_GEN_VERSION=$$(${CONTROLLER_GEN} --version | awk '{print $$2}') ; \ 56 if [ "$${ACTUAL_CONTROLLER_GEN_VERSION}" != "${CONTROLLER_GEN_VERSION}" ] ; then \ 57 echo "Bad controller-gen version $${ACTUAL_CONTROLLER_GEN_VERSION}, please install ${CONTROLLER_GEN_VERSION}" ; \ 58 exit 1; \ 59 fi ; \ 60 } 61 62 # check if the repo is clean after running generate 63 .PHONY: check-repo-clean 64 check-repo-clean: generate manifests 65 ../ci/scripts/check_if_clean_after_generate.sh