-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
55 lines (49 loc) · 1.87 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
MOCK_NAME?=New-mock
K8S_ENV?=namespace
LOCAL_SHELL?=zsh
.PHONY: start clean create apply remove
start:
@echo "## Démarrage du bouchon"
@if [ ! -d ./overlay/$(MOCK_NAME) ]; then \
echo "> Le bouchon $(MOCK_NAME) n'existe pas."; \
exit 2; \
fi
@docker-compose --file ./overlay/$(MOCK_NAME)/docker-compose.yml up
clean:
@echo "## Nettoyage du bouchon local"
@if [ ! -d ./overlay/$(MOCK_NAME) ]; then \
echo "> Le bouchon $(MOCK_NAME) n'existe pas."; \
exit 2; \
fi
@docker-compose --file ./overlay/$(MOCK_NAME)/docker-compose.yml down -v
create:
@echo "## Creation d'un nouveau Mock $(MOCK_NAME)"
@if [ -d "overlay/$(MOCK_NAME)" ]; then \
echo "> Le bouchon $(MOCK_NAME) existe déjà."; \
exit 2; \
fi
@echo "> Duplication du projet Sample vers $(MOCK_NAME)"
@cp -R overlay/galec/ overlay/$(MOCK_NAME)/
@echo "> Modification du fichier de configuration Kustomize"
@sed -i.bck 's/sample/$(MOCK_NAME)/g' overlay/$(MOCK_NAME)/kustomization.yaml
@sed -i.bck 's/sample/$(MOCK_NAME)/g' overlay/$(MOCK_NAME)/README.md
@rm -rf overlay/$(MOCK_NAME)/*.bck
@echo "> N'oubliez pas de mettre à jour la documentation."
apply:
@echo "## Application du bouchon $(MOCK_NAME) sur $(K8S_ENV)"
@if [[ ! "`kubectl get namespaces $(K8S_ENV) -o=jsonpath='{$$.metadata.name}'`" == "$(K8S_ENV)" ]]; then \
echo "> $(K8S_ENV) n'est pas un espace de nom valide."; \
exit 2; \
fi
@if [ ! -d ./overlay/$(MOCK_NAME) ]; then \
echo "> Le bouchon $(MOCK_NAME) n'existe pas."; \
exit 2; \
fi
@kubectl apply -n $(K8S_ENV) -k ./overlay/$(MOCK_NAME)
remove:
@echo "## Suppression du bouchon $(MOCK_NAME) de $(K8S_ENV)"
@if [[ ! "`kubectl get namespaces $(K8S_ENV) -o=jsonpath='{$$.metadata.name}'`" == "$(K8S_ENV)" ]]; then \
echo "> $(K8S_ENV) n'est pas un espace de nom valide."; \
exit 2; \
fi
@kustomize build ./overlay/$(MOCK_NAME) | kubectl delete -n $(K8S_ENV) -f -