-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
103 lines (81 loc) · 4.44 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
.DEFAULT_GOAL: help
SHELL := /bin/bash
PROJECTNAME := "fury-kubernetes-dr"
VERSION := $(shell (git for-each-ref refs/tags --sort=-taggerdate --format='%(refname)' --count=1 | sed -Ee 's/^refs\/tags\/v|-.*//'))
.PHONY: help
all: help
help: Makefile
@echo
@echo " Choose a command to run in "$(PROJECTNAME)":"
@echo
@sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /'
@echo
.PHONY: version
## version: lists the latest version of tool
version:
@echo v$(VERSION)
check-variable-%: # detection of undefined variables.
@[[ "${${*}}" ]] || (echo '*** Please define variable `${*}` ***' && exit 1)
check-release-file-%: # checks if a release doc exists
$(eval tag := `echo "${*}" | sed -e "s/-rc.//"`)
$(eval release_file := "docs/releases/${tag}.md")
@test -f ${release_file} || (echo "*** Please define file ${release_file} ***" && exit 1)
bumpversion-requirements: check-docker
@docker build --no-cache --pull --target bumpversion-requirement -f build/builder/Dockerfile -t ${PROJECTNAME}:local-bumpversion-requirements .
SEMVER_TYPES := major minor patch
BUMP_TARGETS := $(addprefix bump-,$(SEMVER_TYPES))
.PHONY: $(BUMP_TARGETS)
## bump-major: Bumps the module up by a major version
## bump-minor: Bumps the module up by a minor version
## bump-patch: Bumps the module up by a patch version
$(BUMP_TARGETS): bumpversion-requirements
$(eval bump_type := $(strip $(word 2,$(subst -, ,$@))))
@echo "Making a ${bump_type} tag"
@docker run --rm -v ~/.gitconfig:/etc/gitconfig -v ${PWD}:/src -w /src ${PROJECTNAME}:local-bumpversion-requirements $(bump_type)
@$(MAKE) clean-bumpversion-requirements
## bump-rc: Bumps the module up by a release candidate (this only adds a tag, and not bump the version in labels)
.PHONY:
bump-rc: check-variable-TAG check-release-file-$(TAG)
@echo "Making ${TAG} tag"
@git tag ${TAG}
check-%: # detection of required software.
@which ${*} > /dev/null || (echo '*** Please install `${*}` ***' && exit 1)
license-requirements: check-docker
@docker build --no-cache --pull --target add-license-requirement -f build/builder/Dockerfile -t ${PROJECTNAME}:local-license-requirements .
## add-license: Add license headers in all files in the project
add-license: license-requirements
@docker run --rm -v ${PWD}:/src -w /src ${PROJECTNAME}:local-license-requirements addlicense -c "SIGHUP s.r.l" -v -l bsd .
@$(MAKE) clean-license-requirements
## check-license: Check license headers are in-place in all files in the project
check-license: check-docker
@docker build --no-cache --pull --target check-license -f build/builder/Dockerfile -t ${PROJECTNAME}:local-license .
@$(MAKE) clean-license
## check-label: Check if labels are present in all kustomization files
check-label: check-docker
@docker build --no-cache --pull --target checklabel -f build/builder/Dockerfile -t ${PROJECTNAME}:checklabel .
## lint: Run the policeman over the repository
lint: check-docker
@docker build --no-cache --pull --target linter -f build/builder/Dockerfile -t ${PROJECTNAME}:local-lint .
@$(MAKE) clean-lint
## deploy-all: Deploys all the components in the dr module (with velero-on-prem)
deploy-all: deploy-base deploy-on-prem deploy-base deploy-node-agent deploy-schedules
## deploy-base: Deploys the `base` component in the cluster
deploy-base: check-kustomize check-kubectl
@kustomize build katalog/velero/velero-base | kubectl apply -f-
## deploy-on-prem: Deploys the `velero-on-prem` component in the cluster
deploy-on-prem: check-kustomize check-kubectl
@kustomize build katalog/velero/velero-on-prem | kubectl apply -f-
## deploy-node-agent: Deploys the `velero-node-agent` component in the cluster
deploy-node-agent: check-kustomize check-kubectl
@kustomize build katalog/velero/velero-node-agent | kubectl apply -f-
## deploy-schedules: Deploys the `velero-schedules` component in the cluster
deploy-schedules: check-kustomize check-kubectl
@kustomize build katalog/velero/velero-schedules | kubectl apply -f-
## clean-%: Clean the container image resulting from another target. make build clean-build
clean-%:
docker rmi -f ${PROJECTNAME}:local-${*}
jsonbuilder:
@docker build --no-cache --pull --target jsonbuilder -f build/builder/Dockerfile -t ${PROJECTNAME}:jsonbuilder .
## build-canonical-json: Build a canonical JSON for any tag of module, only to be run inside a clean working directory
build-canonical-json: check-docker check-variable-TAG jsonbuilder
@docker run -ti --rm -v $(PWD):/app -w /app ${PROJECTNAME}:jsonbuilder build-json -m=$(PROJECTNAME) -v=${TAG} .