-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
64 lines (52 loc) · 1.98 KB
/
Makefile
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
# GO_BUILD_ARGS should be set when running 'go build' or 'go install'.
VERSION_PKG = "$(shell go list -m)/internal/version"
export GIT_VERSION = $(shell git describe --dirty --tags --always)
export GIT_COMMIT = $(shell git rev-parse HEAD)
BUILD_DIR = $(PWD)/bin
GO_BUILD_ARGS = \
-gcflags "all=-trimpath=$(shell dirname $(shell pwd))" \
-asmflags "all=-trimpath=$(shell dirname $(shell pwd))" \
-ldflags " \
-s \
-w \
-X '$(VERSION_PKG).GitVersion=$(GIT_VERSION)' \
-X '$(VERSION_PKG).GitCommit=$(GIT_COMMIT)' \
" \
# Always use Go modules
export GO111MODULE = on
# This is to allow for building and testing on Apple Silicon.
# These values default to the host's GOOS and GOARCH, but should
# be overridden when running builds and tests on Apple Silicon unless
# you are only building the binary
BUILD_GOOS ?= $(shell go env GOOS)
BUILD_GOARCH ?= $(shell go env GOARCH)
OPERATOR_SDK_REPO_PATH ?= https://github.com/mabulgu/operator-sdk
OPERATOR_SDK_BRANCH ?= rust-operator
OPERATOR_SDK_DIR_NAME ?= operator-sdk
OPERATOR_SDK_BIN_NAME ?= operator-sdk
##@ Development
.PHONY: lint
lint:
@./hack/check-license.sh
@go fmt ./...
##@ Test
.PHONY: test
test:
@go test -coverprofile=coverage.out -covermode=count -short ./...
##@ Build
.PHONY: download-sdk
download-sdk: ## Download Operator SDK
rm -rf $(OPERATOR_SDK_DIR_NAME)
git clone -b $(OPERATOR_SDK_BRANCH) $(OPERATOR_SDK_REPO_PATH)
.PHONY: init-sdk
configure-sdk: download-sdk ## Configure Operator SDK
cd $(OPERATOR_SDK_DIR_NAME) && go mod edit -replace github.com/SystemCraftsman/rust-operator-plugins=..
cd $(OPERATOR_SDK_DIR_NAME) && go mod edit -replace sigs.k8s.io/kubebuilder/v4=github.com/mabulgu/kubebuilder/v4@rust-lang
cd $(OPERATOR_SDK_DIR_NAME) && go mod tidy
.PHONY: build
build: ## Build plugin with Operator SDK
cd $(OPERATOR_SDK_DIR_NAME) && make $@
cp $(OPERATOR_SDK_DIR_NAME)/build/$(OPERATOR_SDK_BIN_NAME) $(BUILD_DIR)
.PHONY: install
install: ## Install Operator SDK CLI
cd $(OPERATOR_SDK_DIR_NAME) && make $@