-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
74 lines (56 loc) · 1.71 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
.DEFAULT_GOAL := build
.PHONY: clean build fmt test
TAG ?= latest
BUILD_FLAGS ?=
BINARY ?= spring-config-decryptor-webhook
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
LDFLAGS ?= -w -s
LOCAL_IMAGE ?= local/$(BINARY)
CLOUD_IMAGE ?= grepplabs/spring-config-decryptor-webhook:$(TAG)
HELM_BIN ?= helm3
HELM_VALUES ?= values.yaml
SVC_NAME ?= spring-config-decryptor-webhook
SVC_NAMESPACE ?= webhook
KUBE_CONTEXT ?= test-cluster
test:
GO111MODULE=on go test -mod=vendor -v ./...
build:
CGO_ENABLED=0 GO111MODULE=on go build -mod=vendor -o $(BINARY) $(BUILD_FLAGS) -ldflags "$(LDFLAGS)" .
fmt:
go fmt ./...
clean:
@rm -rf $(BINARY)
.PHONY: deps
deps:
GO111MODULE=on go get ./...
.PHONY: vendor
vendor:
GO111MODULE=on go mod vendor
.PHONY: tidy
tidy:
GO111MODULE=on go mod tidy
.PHONY: docker-build
docker-build:
docker build -f Dockerfile -t $(LOCAL_IMAGE) .
.PHONY: docker-push
docker-push: docker-build
docker tag $(LOCAL_IMAGE) $(CLOUD_IMAGE)
docker push $(CLOUD_IMAGE)
.PHONY: helm-template
helm-template:
$(HELM_BIN) template $(SVC_NAME) $(ROOT_DIR)/charts/spring-config-decryptor-webhook \
-f $(ROOT_DIR)/charts/spring-config-decryptor-webhook/$(HELM_VALUES) \
--namespace=$(SVC_NAMESPACE)
.PHONY: helm-install
helm-install:
$(HELM_BIN) upgrade $(SVC_NAME) $(ROOT_DIR)/charts/spring-config-decryptor-webhook \
-f $(ROOT_DIR)/charts/spring-config-decryptor-webhook/$(HELM_VALUES) \
--namespace=$(SVC_NAMESPACE) \
--install \
--create-namespace \
--kube-context $(KUBE_CONTEXT)
.PHONY: rollout-restart
rollout-restart:
kubectl rollout restart deployment $(SVC_NAME) \
-n $(SVC_NAMESPACE) \
--context $(KUBE_CONTEXT)