-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
80 lines (66 loc) · 2.54 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
# Make file config
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
WHITE := $(shell tput -Txterm setaf 7)
CYAN := $(shell tput -Txterm setaf 6)
RESET := $(shell tput -Txterm sgr0)
## Help:
help: ## Show this help.
@echo ''
@echo 'Usage:'
@echo ' ${YELLOW}make${RESET} ${GREEN}<target>${RESET}'
@echo ''
@echo 'Targets:'
@awk 'BEGIN {FS = ":.*?## "} { \
if (/^[a-zA-Z_-]+:.*?##.*$$/) {printf " ${YELLOW}%-20s${GREEN}%s${RESET}\n", $$1, $$2} \
else if (/^## .*$$/) {printf " ${CYAN}%s${RESET}\n", substr($$1,4)} \
}' $(MAKEFILE_LIST)
# Location to install dependencies to
LOCALBIN ?= $(shell pwd)/bin
$(LOCALBIN):
mkdir -p $(LOCALBIN)
# Tool Binaries
KUBECTL ?= kubectl
YQ ?= yq
KUSTOMIZE ?= $(LOCALBIN)/kustomize
# Tool Versions
KUSTOMIZE_VERSION ?= v5.3
# Application version
VERSION_NAME := $(shell echo $(VERSION) | sed 's/\./-/g')
.PHONY: kustomize
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary. If wrong version is installed, it will be removed before downloading.
$(KUSTOMIZE): $(LOCALBIN)
@if test -x $(LOCALBIN)/kustomize && ! $(LOCALBIN)/kustomize version | grep -q $(KUSTOMIZE_VERSION); then \
echo "$(LOCALBIN)/kustomize version is not expected $(KUSTOMIZE_VERSION). Removing it before installing."; \
rm -rf $(LOCALBIN)/kustomize; \
fi
test -s $(LOCALBIN)/kustomize || GOBIN=$(LOCALBIN) GO111MODULE=on go install sigs.k8s.io/kustomize/kustomize/v5@$(KUSTOMIZE_VERSION)
.PHONY: release-template
release-template: ## Create release template for catalog and operator
@$(KUSTOMIZE) build operator/setup \
| $(KUBECTL) apply -f -
# @$(KUSTOMIZE) build catalog/setup \
# | $(KUBECTL) apply -f -
.PHONY: release-opeartor
release-operator: check-parameter
release-operator: ## Create new operator release
@$(KUSTOMIZE) build operator/release \
| $(YQ) '.metadata.name += "-"+"$(VERSION_NAME)", .spec.template.values[0].value = "$(VERSION)"' \
| $(KUBECTL) apply -f -
check-parameter:
ifndef VERSION
$(error VERSION parameter not provided)
endif
.PHONY: release-catalog
release-catalog: check-parameter-catalog
OPENSHIFT_VERSION_NAME := $(shell echo $(OPENSHIFT_VERSION) | sed 's/\./-/g')
release-catalog: ## Create new catalog release
@$(KUSTOMIZE) build catalog/release \
| $(YQ) '.metadata.name += "-"+"$(OPENSHIFT_VERSION_NAME)", .spec.template.values[0].value = "$(OPENSHIFT_VERSION)"' \
| $(KUBECTL) apply -f -
check-parameter-catalog:
ifndef OPENSHIFT_VERSION
$(error OPENSHIFT_VERSION parameter not provided)
endif
#.PHONY: create-snapshot
#release-catalog: ## Create override snapshot