1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
types_go_files = $(wildcard ./pkg/types/*.go)
v1_core_go_files = $(wildcard ./pkg/apis/dpf/v1/core/*.go)
v1_contracts_go_files = $(wildcard ./pkg/apis/dpf/v1/contracts/*.go)
v1_common_configs_go_files = $(wildcard ./pkg/apis/dpf/v1/common_configs/*.go)
v1_zones_go_files = $(wildcard ./pkg/apis/dpf/v1/zones/*.go)
v1_lb_domains_go_files = $(wildcard ./pkg/apis/dpf/v1/lb_domains/*.go)
deep_copy_files = pkg/types/ZZ_deepcopy_generated.go \
pkg/apis/dpf/v1/core/ZZ_deepcopy_generated.go \
pkg/apis/dpf/v1/contracts/ZZ_deepcopy_generated.go \
pkg/apis/dpf/v1/zones/ZZ_deepcopy_generated.go \
pkg/apis/dpf/v1/common_configs/ZZ_deepcopy_generated.go \
pkg/apis/dpf/v1/lb_domains/ZZ_deepcopy_generated.go
all: deepcopy fmt checks test
checks: golangci-lint
$(GOLANGCI_LINT) run
test:
go test -coverprofile="cover.out" ./...
go tool cover -html=cover.out -o cover.html
fmt: gofumpt
$(GOFUMPT) -l -w .
deepcopy: $(deep_copy_files)
pkg/types/ZZ_deepcopy_generated.go: deepcopy-gen $(types_go_files)
$(DEEPCOPY_GEN) -O ZZ_deepcopy_generated -h boilerplate.go.txt -i ./pkg/types
pkg/apis/dpf/v1/core/ZZ_deepcopy_generated.go: deepcopy-gen $(v1_core_go_files)
$(DEEPCOPY_GEN) -O ZZ_deepcopy_generated -h boilerplate.go.txt -i ./pkg/apis/dpf/v1/core
pkg/apis/dpf/v1/contracts/ZZ_deepcopy_generated.go: deepcopy-gen $(v1_contracts_go_files)
$(DEEPCOPY_GEN) -O ZZ_deepcopy_generated -h boilerplate.go.txt -i ./pkg/apis/dpf/v1/contracts
pkg/apis/dpf/v1/zones/ZZ_deepcopy_generated.go: deepcopy-gen $(v1_common_configs_go_files)
$(DEEPCOPY_GEN) -O ZZ_deepcopy_generated -h boilerplate.go.txt -i ./pkg/apis/dpf/v1/zones
pkg/apis/dpf/v1/common_configs/ZZ_deepcopy_generated.go: deepcopy-gen $(v1_zones_go_files)
$(DEEPCOPY_GEN) -O ZZ_deepcopy_generated -h boilerplate.go.txt -i ./pkg/apis/dpf/v1/common_configs
pkg/apis/dpf/v1/lb_domains/ZZ_deepcopy_generated.go: deepcopy-gen $(v1_lb_domains_go_files)
$(DEEPCOPY_GEN) -O ZZ_deepcopy_generated -h boilerplate.go.txt -i ./pkg/apis/dpf/v1/lb_domains
DEEPCOPY_GEN = $(PROJECT_DIR)/bin/deepcopy-gen
deepcopy-gen: ## Download deepcopy-gen locally if necessary.
mkdir -p $(PROJECT_DIR)/bin
$(call go-get-tool,$(DEEPCOPY_GEN),k8s.io/code-generator/cmd/deepcopy-gen@latest)
GOFUMPT = $(PROJECT_DIR)/bin/gofumpt
gofumpt:
mkdir -p $(PROJECT_DIR)/bin
$(call go-get-tool,$(GOFUMPT),mvdan.cc/gofumpt@latest)
GOLANGCI_LINT = $(PROJECT_DIR)/bin/golangci-lint
golangci-lint:
mkdir -p $(PROJECT_DIR)/bin
$(call go-get-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint@master)
# go-get-tool will 'go get' any package $2 and install it to $1.
define go-get-tool
@[ -f $(1) ] || { \
set -e ;\
echo "Downloading $(2)" ;\
GOBIN=$(PROJECT_DIR)/bin go install $(2) ;\
}
endef
|