# ==================================================================================== # Setup Project PROJECT_NAME := provider-jet-template PROJECT_REPO := github.com/crossplane-contrib/$(PROJECT_NAME) export TERRAFORM_VERSION := 1.0.11 export TERRAFORM_PROVIDER_SOURCE := hashicorp/hashicups export TERRAFORM_PROVIDER_VERSION := 0.3.2 export TERRAFORM_PROVIDER_DOWNLOAD_NAME := terraform-provider-hashicups export TERRAFORM_PROVIDER_DOWNLOAD_URL_PREFIX := https://github.com/hashicorp/terraform-provider-hashicups/releases/download/v0.3.2 PLATFORMS ?= linux_amd64 linux_arm64 # -include will silently skip missing files, which allows us # to load those files with a target in the Makefile. If only # "include" was used, the make command would fail and refuse # to run a target until the include commands succeeded. -include build/makelib/common.mk # ==================================================================================== # Setup Output -include build/makelib/output.mk # ==================================================================================== # Setup Go # Set a sane default so that the nprocs calculation below is less noisy on the initial # loading of this file NPROCS ?= 1 # each of our test suites starts a kube-apiserver and running many test suites in # parallel can lead to high CPU utilization. by default we reduce the parallelism # to half the number of CPU cores. GO_TEST_PARALLEL := $(shell echo $$(( $(NPROCS) / 2 ))) GO_STATIC_PACKAGES = $(GO_PROJECT)/cmd/provider GO_LDFLAGS += -X $(GO_PROJECT)/internal/version.Version=$(VERSION) GO_SUBDIRS += cmd internal apis GO111MODULE = on -include build/makelib/golang.mk # ==================================================================================== # Setup Kubernetes tools -include build/makelib/k8s_tools.mk # ==================================================================================== # Setup Images DOCKER_REGISTRY ?= crossplane IMAGES = provider-jet-template provider-jet-template-controller -include build/makelib/image.mk # ==================================================================================== # Setup Terraform for fetching provider schema TERRAFORM := $(TOOLS_HOST_DIR)/terraform-$(TERRAFORM_VERSION) TERRAFORM_WORKDIR := $(WORK_DIR)/terraform TERRAFORM_PROVIDER_SCHEMA := config/schema.json $(TERRAFORM): @$(INFO) installing terraform $(HOSTOS)-$(HOSTARCH) @mkdir -p $(TOOLS_HOST_DIR)/tmp-terraform @curl -fsSL https://releases.hashicorp.com/terraform/1.1.4/terraform_1.1.4_$(SAFEHOST_PLATFORM).zip -o $(TOOLS_HOST_DIR)/tmp-terraform/terraform.zip @unzip $(TOOLS_HOST_DIR)/tmp-terraform/terraform.zip -d $(TOOLS_HOST_DIR)/tmp-terraform @mv $(TOOLS_HOST_DIR)/tmp-terraform/terraform $(TERRAFORM) @rm -fr $(TOOLS_HOST_DIR)/tmp-terraform @$(OK) installing terraform $(HOSTOS)-$(HOSTARCH) $(TERRAFORM_PROVIDER_SCHEMA): $(TERRAFORM) @$(INFO) generating provider schema for $(TERRAFORM_PROVIDER_SOURCE) $(TERRAFORM_PROVIDER_VERSION) @mkdir -p $(TERRAFORM_WORKDIR) @echo '{"terraform":[{"required_providers":[{"provider":{"source":"'"$(TERRAFORM_PROVIDER_SOURCE)"'","version":"'"$(TERRAFORM_PROVIDER_VERSION)"'"}}],"required_version":"'"$(TERRAFORM_VERSION)"'"}]}' > $(TERRAFORM_WORKDIR)/main.tf.json @$(TERRAFORM) -chdir=$(TERRAFORM_WORKDIR) init > $(TERRAFORM_WORKDIR)/terraform-logs.txt 2>&1 @$(TERRAFORM) -chdir=$(TERRAFORM_WORKDIR) providers schema -json=true > $(TERRAFORM_PROVIDER_SCHEMA) 2>> $(TERRAFORM_WORKDIR)/terraform-logs.txt @$(OK) generating provider schema for $(TERRAFORM_PROVIDER_SOURCE) $(TERRAFORM_PROVIDER_VERSION) generate.init: $(TERRAFORM_PROVIDER_SCHEMA) # ==================================================================================== # Targets # run `make help` to see the targets and options # We want submodules to be set up the first time `make` is run. # We manage the build/ folder and its Makefiles as a submodule. # The first time `make` is run, the includes of build/*.mk files will # all fail, and this target will be run. The next time, the default as defined # by the includes will be run instead. fallthrough: submodules @echo Initial setup complete. Running make again . . . @make # NOTE: the build submodule currently overrides XDG_CACHE_HOME in order to # force the Helm 3 to use the .work/helm directory. This causes Go on Linux # machines to use that directory as the build cache as well. We should adjust # this behavior in the build submodule because it is also causing Linux users # to duplicate their build cache, but for now we just make it easier to identify # its location in CI so that we cache between builds. go.cachedir: @go env GOCACHE # Generate a coverage report for cobertura applying exclusions on # - generated file cobertura: @cat $(GO_TEST_OUTPUT)/coverage.txt | \ grep -v zz_ | \ $(GOCOVER_COBERTURA) > $(GO_TEST_OUTPUT)/cobertura-coverage.xml crds.clean: @$(INFO) cleaning generated CRDs @find package/crds -name '*.yaml' -exec sed -i.sed -e '1,2d' {} \; || $(FAIL) @find package/crds -name '*.yaml.sed' -delete || $(FAIL) @$(OK) cleaned generated CRDs generate.done: crds.clean # Update the submodules, such as the common build scripts. submodules: @git submodule sync @git submodule update --init --recursive # This is for running out-of-cluster locally, and is for convenience. Running # this make target will print out the command which was used. For more control, # try running the binary directly with different arguments. run: go.build @$(INFO) Running Crossplane locally out-of-cluster . . . @# To see other arguments that can be provided, run the command with --help instead $(GO_OUT_DIR)/provider --debug .PHONY: cobertura submodules fallthrough run crds.clean # ==================================================================================== # Special Targets define CROSSPLANE_MAKE_HELP Crossplane Targets: cobertura Generate a coverage report for cobertura applying exclusions on generated files. submodules Update the submodules, such as the common build scripts. run Run crossplane locally, out-of-cluster. Useful for development. endef # The reason CROSSPLANE_MAKE_HELP is used instead of CROSSPLANE_HELP is because the crossplane # binary will try to use CROSSPLANE_HELP if it is set, and this is for something different. export CROSSPLANE_MAKE_HELP crossplane.help: @echo "$$CROSSPLANE_MAKE_HELP" help-special: crossplane.help .PHONY: crossplane.help help-special