-
Notifications
You must be signed in to change notification settings - Fork 8
/
Makefile
79 lines (61 loc) · 3.05 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
VERSION = 1.10.1
# IMPORTANT! Update api version if a new release affects cnr
API_VERSION = 1.0.0
IMAGE = cyclops:$(VERSION)
ENVVAR ?= CGO_ENABLED=0
ARCH=$(if $(TARGETPLATFORM),$(lastword $(subst /, ,$(TARGETPLATFORM))),amd64)
BASE_PACKAGE = github.com/atlassian-labs/cyclops/pkg
CLI_BUILD_LD_FLAGS= -X 'main.version=${VERSION}' -X '${BASE_PACKAGE}/cli.apiVersion=${API_VERSION}'
OBSERVER_BUILD_LD_FLAGS = -X 'main.version=${VERSION}' -X '${BASE_PACKAGE}/observer.apiVersion=${API_VERSION}'
MANAGER_BUILD_LD_FLAGS = -X 'main.version=${VERSION}' -X '${BASE_PACKAGE}/controller/cyclenoderequest.apiVersion=${API_VERSION}'
MANAGER_BIN = cyclops
CLI_BIN = kubectl-cycle
OBSERVER_BIN = observer
.PHONY: build-manager build-observer build-cli install-cli build docker build-manager-linux build-observer-linux build-cli-linux build-linux docker-save local srcclr
.DEFAULT_GOAL := build
install-cli:
go build -o ${GOPATH}/bin/${CLI_BIN} -ldflags="${CLI_BUILD_LD_FLAGS}" cmd/cli/main.go
build-observer:
go build -o bin/${OBSERVER_BIN} -ldflags="${OBSERVER_BUILD_LD_FLAGS}" cmd/observer/main.go
build-manager:
go build -o bin/${MANAGER_BIN} -ldflags="${MANAGER_BUILD_LD_FLAGS}" cmd/manager/main.go
build-cli:
go build -o bin/${CLI_BIN} -ldflags="${CLI_BUILD_LD_FLAGS}" cmd/cli/main.go
build: build-manager build-cli build-observer
build-manager-linux:
$(ENVVAR) GOOS=linux GOARCH=$(ARCH) go build -a -installsuffix cgo -o bin/linux/${MANAGER_BIN} -ldflags="${MANAGER_BUILD_LD_FLAGS}" cmd/manager/main.go
build-cli-linux:
$(ENVVAR) GOOS=linux GOARCH=$(ARCH) go build -a -installsuffix cgo -o bin/linux/${CLI_BIN} -ldflags="${CLI_BUILD_LD_FLAGS}" cmd/cli/main.go
build-observer-linux:
$(ENVVAR) GOOS=linux GOARCH=$(ARCH) go build -a -installsuffix cgo -o bin/linux/${OBSERVER_BIN} -ldflags="${OBSERVER_BUILD_LD_FLAGS}" cmd/observer/main.go
build-linux: build-manager-linux build-cli-linux build-observer-linux
clean:
rm -f bin/${MANAGER_BIN}
rm -f bin/${CLI_BIN}
rm -f bin/${OBSERVER_BIN}
rm -f bin/linux/${MANAGER_BIN}
rm -f bin/linux/${CLI_BIN}
rm -f bin/linux/${OBSERVER_BIN}
test:
go test -cover ./pkg/...
go test -cover ./cmd/...
lint:
golangci-lint run
docker:
docker buildx build --build-arg ENVVAR="$(ENVVAR)" -t $(IMAGE) --platform linux/$(ARCH) .
# New version of operator-sdk no longer support generate CRDs directly
# Build from release v0.19.0 with commit hash
install-operator-sdk:
mkdir -p $(GOPATH)/src/github.com/operator-framework
-cd $(GOPATH)/src/github.com/operator-framework && git clone https://github.com/operator-framework/operator-sdk
git -C $(GOPATH)/src/github.com/operator-framework/operator-sdk checkout master
git -C $(GOPATH)/src/github.com/operator-framework/operator-sdk checkout tags/v0.19.0
$(MAKE) -C $(GOPATH)/src/github.com/operator-framework/operator-sdk tidy
$(MAKE) -C $(GOPATH)/src/github.com/operator-framework/operator-sdk install
# See https://sdk.operatorframework.io/docs/golang/quickstart/
generate-crds:
mkdir -p build deploy/crds
touch build/Dockerfile
operator-sdk generate k8s
operator-sdk generate crds --crd-version v1
rm -rf build/