-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
101 lines (79 loc) · 3.07 KB
/
Makefile
File metadata and controls
101 lines (79 loc) · 3.07 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# Image URL to use all building/pushing image targets
IMG ?= cr-hn-1.bizflycloud.vn/31ff9581861a4d0ea4df5e7dda0f665d/karpenter-provider-bizflycloud:latest
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.32.1
# Obtain the version using git describe, defaulting to 'dev' if git is not available
VERSION ?= $(shell git describe --tags --always 2>/dev/null || echo "dev")
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
endif
# Setting SHELL to bash allows bash commands to be executed by recipes.
# Options are set to exit when a recipe line exits non-zero or a piped command fails.
SHELL = /usr/bin/env bash -o pipefail
.SHELLFLAGS = -ec
# LDFLAGS for the build
LDFLAGS = -ldflags "-X main.version=$(VERSION) -X main.buildDate=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')"
MODULE := github.com/bizflycloud/karpenter-provider-bizflycloud
APIS := ./pkg/apis/v1
BOILERPLATE := ./hack/boilerplate.go.txt
CRD_OUTPUT := ./config/crd
CONTROLLER_GEN := $(shell which controller-gen)
.PHONY: generate
generate: deepcopy crd
deepcopy:
@echo "🧬 Generating deepcopy methods..."
$(CONTROLLER_GEN) object:headerFile="$(BOILERPLATE)" paths="$(APIS)"
crd:
@echo "📦 Generating CRDs..."
$(CONTROLLER_GEN) crd:crdVersions=v1 object:headerFile="$(BOILERPLATE)" paths="$(APIS)" output:crd:dir="$(CRD_OUTPUT)"
clean:
@echo "🧹 Cleaning generated files..."
find $(APIS) -name "zz_generated.deepcopy.go" -delete
rm -rf $(CRD_OUTPUT)/*.yaml
.PHONY: all
all: build
.PHONY: manifests
manifests: ## Generate CRDs and RBAC.
@echo "Validating CRDs..."
@kubectl validate --schema $(shell kubectl api-resources --api-group=apiextensions.k8s.io -o name | grep customresourcedefinition) -f config/crd/karpenter.bizflycloud.com_providerconfigs.yaml
##@ Build
.PHONY: fmt
fmt: ## Run go fmt against code.
go fmt ./...
.PHONY: vet
vet: ## Run go vet against code.
go vet ./...
.PHONY: lint
lint: ## Run golangci-lint against code.
golangci-lint run
.PHONY: test
test: fmt vet ## Run tests.
go test ./... -v
.PHONY: build
build: fmt vet ## Build manager binary.
go build $(LDFLAGS) -o bin/karpenter-provider-bizflycloud cmd/controller/main.go
.PHONY: run
run: fmt vet ## Run from your host.
go run $(LDFLAGS) ./cmd/controller/main.go
.PHONY: docker-build
docker-build: ## Build docker image with the manager.
docker build --platform=linux/amd64 --build-arg VERSION=$(VERSION) -t ${IMG} .
.PHONY: docker-push
docker-push: ## Push docker image with the manager.
docker push ${IMG}
##@ Deployment
.PHONY: install-crds
install-crds: ## Install CRDs into a cluster.
kubectl apply -f config/crd/
.PHONY: uninstall-crds
uninstall-crds: ## Uninstall CRDs from a cluster.
kubectl delete -f config/crd/
.PHONY: deploy
deploy: install-crds ## Deploy to the K8s cluster specified in ~/.kube/config.
kubectl apply -f config/
.PHONY: undeploy
undeploy: ## Undeploy from the K8s cluster specified in ~/.kube/config.
kubectl delete -f config/