-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
118 lines (97 loc) · 3.58 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
PROJECTNAME := $(shell basename "$(PWD)")
# Go related variables.
PROJECTROOT := $(shell pwd)
GOBIN := $(PROJECTROOT)/bin
# Shell script related variables.
UTILDIR := $(PROJECTROOT)/scripts/utils
SPINNER := $(UTILDIR)/spinner.sh
BUILDIR := $(PROJECTROOT)/scripts/build
MANIFEST:= $(PROJECTROOT)/kubernetes/manifests
KEY_NAME := team
NO_OF_TEAMS:= 10
OPENVPN_NAMESPACE := openvpn
POD_COMMAND =$(shell kubectl get pods --namespace $(OPENVPN_NAMESPACE) -l "app=openvpn,release=openvpn" -o jsonpath='{ .items[0].metadata.name }')
SERVICE_NAME_COMMAND =$(shell kubectl get svc --namespace $(OPENVPN_NAMESPACE) -l "app=openvpn,release=openvpn" -o jsonpath='{ .items[0].metadata.name }')
SERVICE_IP_COMMAND=$(shell kubectl get svc --namespace $(OPENVPN_NAMESPACE) -l "app=openvpn,release=openvpn" -o jsonpath='{.items[0].status.loadBalancer.ingress[0].ip}')
# CHALLENGE_DEPLOYER_IP := $(shell minikube service nginx-ingress-controller --url -n kube-system)
# Make is verbose in Linux. Make it silent.
MAKEFLAGS += --silent
.PHONY: default
default: help
## Build the cli binary
build-cli:
@printf "🔨 Building binary $(GOBIN)/$(PROJECTNAME)\n"
@./scripts/build/build-cli.sh
# @cp ./cli/$(PROJECTNAME) $(GOBIN)/
@printf "👍 Done\n"
## Lint the code
install-golint:
@printf "🔨 Installing golint\n"
@./scripts/install-golint.sh
@printf "👍 Done\n"
## Format the code
fmt:
@printf "🔨 Formatting\n"
@gofmt -l -s .
@printf "👍 Done\n"
## Check codebase for style mistakes
lint: install-golint
@printf "🔨 Linting\n"
@golangci-lint run
@printf "👍 Done\n"
## Clean build files
clean:
@printf "🔨 Cleaning build cache\n"
@go clean .
@printf "👍 Done\n"
@-rm $(GOBIN)/* 2>/dev/null
## Prepare code for PR
prepare-for-pr: fmt lint
@git diff-index --quiet HEAD -- ||\
(echo "-----------------" &&\
echo "NOTICE: There are some files that have not been committed." &&\
echo "-----------------\n" &&\
git status &&\
echo "\n-----------------" &&\
echo "NOTICE: There are some files that have not been committed." &&\
echo "-----------------\n" &&\
exit 0)
gen-certificates:
$(eval POD_NAME := $(POD_COMMAND))
$(eval SERVICE_NAME := $(SERVICE_NAME_COMMAND))
$(eval SERVICE_IP := $(SERVICE_IP_COMMAND))
for n in $$(seq 1 $(NO_OF_TEAMS)); do \
kubectl --namespace $(OPENVPN_NAMESPACE) exec -it $(POD_NAME) /etc/openvpn/setup/newClientCert.sh $(KEY_NAME)-$$n $(SERVICE_IP) && \
kubectl --namespace $(OPENVPN_NAMESPACE) exec -it $(POD_NAME) cat "/etc/openvpn/certs/pki/$(KEY_NAME)-$$n.ovpn" > $(KEY_NAME)-$$n.ovpn; \
done
set-env: build
minikube start --driver=docker && \
minikube addons enable ingress && \
kubectl apply -f $(MANIFEST) && \
cp config.sample.toml config.toml && \
./bin/katana run
set-env-prod: build
kubectl apply -f $(MANIFEST) && \
cp config.sample.toml config.toml && \
sudo ./bin/katana run
build:
cd cmd && go build -o ../bin/katana
run : build
sudo ./bin/katana run
setup-docs:
git submodule update --init --recursive
cp ./docs/config.sample.toml ./docs/config.toml
npm install --prefix ./docs/themes/hugo-geekdoc
npm run build --prefix ./docs/themes/hugo-geekdoc
# Prints help message
help:
@echo "KATANA"
@echo "build-cli - Build katana"
@echo "fmt - Format code using golangci-lint"
@echo "help - Prints help message"
@echo "install-golint - Install golint"
@echo "clean - Clean the build cache"
@echo "prepare-for-pr - Prepare the code for PR after fmt, lint and checking uncommitted files"
@echo "lint - Lint code using golangci-lint"
@echo "set-env" - Setup Katana environment
@echo "build" - Build katana binary