-
Notifications
You must be signed in to change notification settings - Fork 112
/
Makefile
54 lines (48 loc) · 1.96 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
SHELL := /bin/bash
# build.e2e builds the nats-operator-e2e test binary.
.PHONY: build.e2e
build.e2e:
@GOOS=linux GOARCH=amd64 go test -tags e2e -c -o build/nats-operator-e2e ./test/e2e/*.go
# build.operator builds the nats-operator binary.
.PHONY: build.operator
build.operator: gen
@GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build \
-ldflags "-d -s -w -X github.com/nats-io/nats-operator/version.GitSHA=`git rev-parse --short HEAD`" \
-tags netgo \
-installsuffix cgo \
-o build/nats-operator ./cmd/operator/main.go
# e2e runs the end-to-end test suite.
.PHONY: e2e
e2e: FEATURE_GATE_CLUSTER_SCOPED ?= false
e2e: KUBECONFIG ?= $(HOME)/.kube/config
e2e: NAMESPACE ?= default
e2e:
FEATURE_GATE_CLUSTER_SCOPED=$(FEATURE_GATE_CLUSTER_SCOPED) MODE=run NAMESPACE=$(NAMESPACE) PROFILE=local TARGET=operator $(MAKE) run
FEATURE_GATE_CLUSTER_SCOPED=$(FEATURE_GATE_CLUSTER_SCOPED) MODE=run NAMESPACE=$(NAMESPACE) PROFILE=local TARGET=e2e $(MAKE) run
@go test -timeout 20m -tags e2e -v ./test/e2e/main_test.go -feature-gates=ClusterScoped=$(FEATURE_GATE_CLUSTER_SCOPED) -kubeconfig $(KUBECONFIG) -namespace $(NAMESPACE) -wait
# run deploys either nats-operator or nats-operator-e2e to the Kubernetes cluster targeted by the current kubeconfig.
.PHONY: run
run: FEATURE_GATE_CLUSTER_SCOPED ?= false
run: MODE ?= dev
run: NAMESPACE ?= default
run: PROFILE ?= local
run: TARGET ?= operator
run:
@FEATURE_GATE_CLUSTER_SCOPED=$(FEATURE_GATE_CLUSTER_SCOPED) MODE=$(MODE) NAMESPACE=$(NAMESPACE) PROFILE=$(PROFILE) TARGET=$(TARGET) $(PWD)/hack/skaffold.sh
# gen executes the code generation step.
gen:
@./hack/codegen.sh
.PHONY: dockerx
dockerx:
ifneq ($(ver),)
# Ensure 'docker buildx ls' shows correct platforms.
docker buildx build \
--tag natsio/nats-operator:$(ver) --tag natsio/nats-operator:latest \
--platform linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8 \
--file docker/operator/Dockerfile \
--push .
else
# Missing version, try this.
# make dockerx ver=1.2.3
exit 1
endif