forked from kedacore/keda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
127 lines (105 loc) · 4.55 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
##################################################
# Variables #
##################################################
VERSION ?= master
IMAGE_REGISTRY ?= docker.io
IMAGE_REPO ?= kedacore
IMAGE_CONTROLLER = $(IMAGE_REGISTRY)/$(IMAGE_REPO)/keda:$(VERSION)
IMAGE_ADAPTER = $(IMAGE_REGISTRY)/$(IMAGE_REPO)/keda-metrics-adapter:$(VERSION)
IMAGE_BUILD_TOOLS = $(IMAGE_REGISTRY)/$(IMAGE_REPO)/build-tools:latest
ARCH ?=amd64
CGO ?=0
TARGET_OS ?=linux
GIT_VERSION = $(shell git describe --always --abbrev=7)
GIT_COMMIT = $(shell git rev-list -1 HEAD)
DATE = $(shell date -u +"%Y.%m.%d.%H.%M.%S")
TEST_CLUSTER_NAME ?= keda-nightly-run
##################################################
# All #
##################################################
.PHONY: All
all: test build
##################################################
# Tests #
##################################################
.PHONY: test
test:
go test ./... -covermode=atomic -coverprofile cover.out
.PHONY: e2e-test
e2e-test:
TERMINFO=/etc/terminfo
TERM=linux
@az login --service-principal -u $(AZURE_SP_ID) -p "$(AZURE_SP_KEY)" --tenant $(AZURE_SP_TENANT)
@az aks get-credentials \
--name $(TEST_CLUSTER_NAME) \
--subscription $(AZURE_SUBSCRIPTION) \
--resource-group $(AZURE_RESOURCE_GROUP)
npm install --prefix tests
IMAGE_CONTROLLER=$(IMAGE_CONTROLLER) IMAGE_ADAPTER=$(IMAGE_ADAPTER) ./tests/run-all.sh
##################################################
# PUBLISH #
##################################################
.PHONY: publish
publish: build
docker push $(IMAGE_ADAPTER)
docker push $(IMAGE_CONTROLLER)
##################################################
# Release #
##################################################
K8S_DEPLOY_FILES = $(shell find ./deploy -name '*.yaml')
.PHONY: set-version
set-version:
@sed -i 's@Version =.*@Version = "$(VERSION)"@g' ./version/version.go;
@for file in $(K8S_DEPLOY_FILES); do \
sed -i '[email protected]/version:.*@app.kubernetes.io/version: "$(VERSION)"@g' $$file; \
sed -i 's@image: docker.io/kedacore/keda:.*@image: docker.io/kedacore/keda:$(VERSION)@g' $$file; \
sed -i 's@image: docker.io/kedacore/keda-metrics-adapter:.*@image: docker.io/kedacore/keda-metrics-adapter:$(VERSION)@g' $$file; \
done
.PHONY: release
release:
rm -rf ./keda-$(VERSION)
rm -f ./keda-$(VERSION).tar.gz
rm -f ./keda-$(VERSION).zip
mkdir -p ./keda-$(VERSION)/crds
cp -r ./deploy/*.yaml ./keda-$(VERSION)
cp ./deploy/crds/*_crd.yaml ./keda-$(VERSION)/crds
tar -z -cf ./keda-$(VERSION).tar.gz keda-$(VERSION)/
zip -r ./keda-$(VERSION).zip keda-$(VERSION)/
rm -rf ./keda-$(VERSION)
##################################################
# Build #
##################################################
GO_BUILD_VARS= GO111MODULE=on CGO_ENABLED=$(CGO) GOOS=$(TARGET_OS) GOARCH=$(ARCH)
.PHONY: checkenv
checkenv:
ifndef GOROOT
@echo "WARNING: GOROOT is not defined"
endif
.PHONY: build
build: checkenv build-adapter build-controller
.PHONY: build-controller
build-controller: generate-api pkg/scalers/liiklus/LiiklusService.pb.go
$(GO_BUILD_VARS) operator-sdk build $(IMAGE_CONTROLLER) \
--go-build-args "-ldflags -X=github.com/kedacore/keda/version.Version=$(VERSION) -o build/_output/bin/keda"
.PHONY: build-adapter
build-adapter: generate-api pkg/scalers/liiklus/LiiklusService.pb.go
$(GO_BUILD_VARS) go build \
-ldflags "-X=github.com/kedacore/keda/version.GitCommit=$(GIT_COMMIT) -X=github.com/kedacore/keda/version.Version=$(VERSION)" \
-o build/_output/bin/keda-adapter \
cmd/adapter/main.go
docker build -f build/Dockerfile.adapter -t $(IMAGE_ADAPTER) .
.PHONY: generate-api
generate-api:
$(GO_BUILD_VARS) operator-sdk generate k8s
$(GO_BUILD_VARS) operator-sdk generate openapi
pkg/scalers/liiklus/LiiklusService.pb.go: hack/LiiklusService.proto
protoc -I hack/ hack/LiiklusService.proto --go_out=plugins=grpc:pkg/scalers/liiklus
pkg/scalers/liiklus/mocks/mock_liiklus.go: pkg/scalers/liiklus/LiiklusService.pb.go
mockgen github.com/kedacore/keda/pkg/scalers/liiklus LiiklusServiceClient > pkg/scalers/liiklus/mocks/mock_liiklus.go
##################################################
# Build Tools Image #
##################################################
.PHONY: publish-build-tools
publish-build-tools:
docker build -f tools/build-tools.Dockerfile -t $(IMAGE_BUILD_TOOLS) .
docker push $(IMAGE_BUILD_TOOLS)