|
| 1 | +include makefiles/const.mk |
| 2 | +include makefiles/build-image.mk |
| 3 | +include makefiles/build-swagger.mk |
| 4 | +include makefiles/build-bundle.mk |
| 5 | +include makefiles/build-catalog.mk |
| 6 | +include makefiles/build-helm-package.mk |
| 7 | +include makefiles/dependency.mk |
| 8 | + |
| 9 | +# VERSION defines the project version for the bundle. |
| 10 | +# Update this value when you upgrade the version of your project. |
| 11 | +# To re-generate a bundle for another specific version without changing the standard setup, you can: |
| 12 | +# - use the VERSION as arg of the bundle target (e.g make bundle VERSION=0.0.2) |
| 13 | +# - use environment variables to overwrite this value (e.g export VERSION=0.0.2) |
| 14 | +VERSION ?= 0.0.1 |
| 15 | + |
| 16 | +.PHONY: all |
| 17 | +all: build |
| 18 | + |
| 19 | +##@ General |
| 20 | + |
| 21 | +# The help target prints out all targets with their descriptions organized |
| 22 | +# beneath their categories. The categories are represented by '##@' and the |
| 23 | +# target descriptions by '##'. The awk commands is responsible for reading the |
| 24 | +# entire set of makefiles included in this invocation, looking for lines of the |
| 25 | +# file as xyz: ## something, and then pretty-format the target and help. Then, |
| 26 | +# if there's a line with ##@ something, that gets pretty-printed as a category. |
| 27 | +# More info on the usage of ANSI control characters for terminal formatting: |
| 28 | +# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters |
| 29 | +# More info on the awk command: |
| 30 | +# http://linuxcommand.org/lc3_adv_awk.php |
| 31 | + |
| 32 | +.PHONY: help |
| 33 | +help: ## Display this help. |
| 34 | + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) |
| 35 | + |
| 36 | +##@ Development |
| 37 | +cli: ## Generate bdcctl cli. |
| 38 | + go build -o bdcctl reference/cmd/cli/main.go |
| 39 | + |
| 40 | +.PHONY: manifests |
| 41 | +manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects. |
| 42 | + $(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./api/..." output:crd:artifacts:config=config/crd/bases |
| 43 | + |
| 44 | +.PHONY: cp |
| 45 | +cp: ## Copy CRD files to helm chart. |
| 46 | + cp -r config/crd/bases/*.yaml charts/kdp-oam-operator/crds |
| 47 | + |
| 48 | +.PHONY: generate |
| 49 | +generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations. |
| 50 | + $(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..." |
| 51 | + |
| 52 | +.PHONY: fmt |
| 53 | +fmt: ## Run go fmt against code. |
| 54 | + go fmt ./... |
| 55 | + |
| 56 | +.PHONY: vet |
| 57 | +vet: ## Run go vet against code. |
| 58 | + go vet ./... |
| 59 | + |
| 60 | + |
| 61 | +.PHONY: test |
| 62 | +test: manifests generate cp fmt vet env-test ## Run tests. |
| 63 | + KUBEBUILDER_ASSETS="$(shell $(ENV_TEST) use $(ENV_TEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test $(shell go list ./pkg/...) -coverprofile cover.out && go tool cover -func=cover.out |
| 64 | + $(ENV_TEST) cleanup $(ENV_TEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path |
| 65 | + |
| 66 | +.PHONY: clean |
| 67 | +clean: ## clean up env-test binary. |
| 68 | + if [[ -d $(LOCALBIN)/k8s ]]; then \ |
| 69 | + rm -rf $(LOCALBIN)/k8s; \ |
| 70 | + fi |
| 71 | + |
| 72 | + |
| 73 | +##@ Deployment |
| 74 | + |
| 75 | +.PHONY: build |
| 76 | +build: manifests generate fmt vet ## Build manager binary. |
| 77 | + go build -o bin/manager cmd/bdc/main.go |
| 78 | + |
| 79 | +.PHONY: run |
| 80 | +run: manifests generate fmt vet ## Run a controller from your host. |
| 81 | + go run cmd/bdc/main.go |
| 82 | + |
| 83 | +ifndef ignore-not-found |
| 84 | + ignore-not-found = false |
| 85 | +endif |
| 86 | + |
| 87 | +.PHONY: install |
| 88 | +install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config. |
| 89 | + $(KUSTOMIZE) build config/crd | kubectl apply -f - |
| 90 | + |
| 91 | + |
| 92 | +.PHONY: uninstall |
| 93 | +uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion. |
| 94 | + $(KUSTOMIZE) build config/crd | kubectl delete --ignore-not-found=$(ignore-not-found) -f - |
| 95 | + |
| 96 | +.PHONY: deploy |
| 97 | +deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config. |
| 98 | + cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG_CONTROLLER} |
| 99 | + $(KUSTOMIZE) build config/default | kubectl apply -f - |
| 100 | + |
| 101 | +.PHONY: undeploy |
| 102 | +undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion. |
| 103 | + $(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f - |
| 104 | + |
| 105 | +.PHONY: apply |
| 106 | +apply: manifests kustomize ## Apply samples into the K8s cluster specified in ~/.kube/config. |
| 107 | + $(KUSTOMIZE) build config/samples | kubectl apply -f - |
| 108 | + |
| 109 | +.PHONY: delete |
| 110 | +delete: manifests kustomize ## Delete samples from the K8s cluster specified in ~/.kube/config. |
| 111 | + $(KUSTOMIZE) build config/samples | kubectl delete -f - |
| 112 | + |
| 113 | +.PHONY: run-apiserver |
| 114 | +run-apiserver: fmt vet ## Run a api server from your host. |
| 115 | + go run cmd/apiserver/main.go --kube-api-qps=300 --kube-api-burst=900 |
0 commit comments