Skip to content

Commit 3c94ef3

Browse files
pmacikopenshift-merge-robot
authored andcommitted
Reduce and unify examples' Makefiles by using the Commons. (redhat-developer#192)
* Reduce and unify examples' Makefiles by using the Commons. * Remove unnecessary part of the commons.mk
1 parent 542d4af commit 3c94ef3

File tree

10 files changed

+265
-509
lines changed

10 files changed

+265
-509
lines changed

examples/commons.mk

Lines changed: 237 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,237 @@
1+
# It's necessary to set this because some environments don't link sh -> bash.
2+
SHELL := /bin/bash
3+
4+
#-----------------------------------------------------------------------------
5+
# VERBOSE target
6+
#-----------------------------------------------------------------------------
7+
8+
# When you run make VERBOSE=1 (the default), executed commands will be printed
9+
# before executed. If you run make VERBOSE=2 verbose flags are turned on and
10+
# quiet flags are turned off for various commands. Use V_FLAG in places where
11+
# you can toggle on/off verbosity using -v. Use Q_FLAG in places where you can
12+
# toggle on/off quiet mode using -q. Use S_FLAG where you want to toggle on/off
13+
# silence mode using -s...
14+
VERBOSE ?= 1
15+
Q = @
16+
Q_FLAG = -q
17+
QUIET_FLAG = --quiet
18+
V_FLAG =
19+
VERBOSE_FLAG =
20+
S_FLAG = -s
21+
X_FLAG =
22+
ifeq ($(VERBOSE),1)
23+
Q =
24+
endif
25+
ifeq ($(VERBOSE),2)
26+
Q =
27+
Q_FLAG =
28+
QUIET_FLAG =
29+
S_FLAG =
30+
V_FLAG = -v
31+
VERBOSE_FLAG = --verbose
32+
X_FLAG = -x
33+
endif
34+
35+
#-----------------------------------------------------------------------------
36+
# Examples Commons
37+
#-----------------------------------------------------------------------------
38+
EC=$(SHELL) -c '. ../../hack/examples-commons.sh && $$1' EC
39+
40+
export HACK_YAMLS=../../hack/yamls
41+
42+
## -- Commmon Utility targets --
43+
44+
## Print help message for all Makefile targets
45+
## Run `make` or `make help` to see the help
46+
.PHONY: help
47+
help: ## Credit: https://gist.github.com/prwhite/8168133#gistcomment-2749866
48+
49+
@printf "Usage:\n make <target>";
50+
51+
@awk '{ \
52+
if ($$0 ~ /^.PHONY: [a-zA-Z\-\_0-9]+$$/) { \
53+
helpCommand = substr($$0, index($$0, ":") + 2); \
54+
if (helpMessage) { \
55+
printf "\033[36m%-20s\033[0m %s\n", \
56+
helpCommand, helpMessage; \
57+
helpMessage = ""; \
58+
} \
59+
} else if ($$0 ~ /^[a-zA-Z\-\_0-9.]+:/) { \
60+
helpCommand = substr($$0, 0, index($$0, ":")); \
61+
if (helpMessage) { \
62+
printf "\033[36m%-20s\033[0m %s\n", \
63+
helpCommand, helpMessage; \
64+
helpMessage = ""; \
65+
} \
66+
} else if ($$0 ~ /^##/) { \
67+
if (helpMessage) { \
68+
helpMessage = helpMessage"\n "substr($$0, 3); \
69+
} else { \
70+
helpMessage = substr($$0, 3); \
71+
} \
72+
} else { \
73+
if (helpMessage) { \
74+
print "\n "helpMessage"\n" \
75+
} \
76+
helpMessage = ""; \
77+
} \
78+
}' \
79+
$(MAKEFILE_LIST)
80+
81+
## -- Common Cluster Admin Targets --
82+
83+
# === Service Bidining Operator ===
84+
85+
.PHONY: install-service-binding-operator-source
86+
## Install the Service Binding Operator Source
87+
install-service-binding-operator-source:
88+
${Q}${EC} install_service_binding_operator_source
89+
90+
.PHONY: install-service-binding-operator-subscription
91+
## Install the Service Binding Operator Subscription
92+
install-service-binding-operator-subscription:
93+
${Q}${EC} install_service_binding_operator_subscription
94+
95+
.PHONY: install-service-binding-operator
96+
## Install the Service Binding Operator
97+
install-service-binding-operator: install-service-binding-operator-source install-service-binding-operator-subscription
98+
99+
.PHONY: uninstall-service-binding-operator-source
100+
## Uninstall the Service Binding Operator Source
101+
uninstall-service-binding-operator-source:
102+
${Q}${EC} uninstall_service_binding_operator_source
103+
104+
.PHONY: uninstall-service-binding-operator-subscription
105+
## Uninstall the Service Binding Operator Subscription
106+
uninstall-service-binding-operator-subscription:
107+
${Q}${EC} uninstall_service_binding_operator_subscription
108+
109+
.PHONY: uninstall-service-binding-operator
110+
## Uninstall the Service Binding Operator
111+
uninstall-service-binding-operator: uninstall-service-binding-operator-source uninstall-service-binding-operator-subscription
112+
113+
# === Backing Service DB (PostgreSQL) Operator ===
114+
115+
.PHONY: install-backing-db-operator-source
116+
## Install the Backing Service DB Operator Source
117+
install-backing-db-operator-source:
118+
${Q}${EC} install_postgresql_operator_source
119+
120+
.PHONY: install-backing-db-operator-subscription
121+
## Install the Backing Service DB Operator Subscription
122+
install-backing-db-operator-subscription:
123+
${Q}${EC} install_postgresql_operator_subscription
124+
125+
.PHONY: install-backing-db-operator
126+
## Install the Backing Service DB Operator
127+
install-backing-db-operator: install-backing-db-operator-source install-backing-db-operator-subscription
128+
129+
.PHONY: uninstall-backing-db-operator-source
130+
## Uninstall the Backing Service DB Operator Source
131+
uninstall-backing-db-operator-source:
132+
${Q}${EC} uninstall_postgresql_operator_source
133+
134+
.PHONY: uninstall-backing-db-operator-subscription
135+
## Uninstall the Backing Service DB Operator Subscription
136+
uninstall-backing-db-operator-subscription:
137+
${Q}${EC} uninstall_postgresql_operator_subscription
138+
139+
.PHONY: uninstall-backing-db-operator
140+
## Uninstall the Backing Service DB Operator
141+
uninstall-backing-db-operator: uninstall-backing-db-operator-source uninstall-backing-db-operator-subscription
142+
143+
# === Serverless Operator ===
144+
145+
.PHONY: install-serverless-operator-source
146+
## Install the Serverless Operator Source
147+
install-serverless-operator-source:
148+
${Q}${EC} install_postgresql_operator_source
149+
150+
.PHONY: install-serverless-operator-subscription
151+
## Install the Serverless Operator Subscription
152+
install-serverless-operator-subscription:
153+
${Q}${EC} install_postgresql_operator_subscription
154+
155+
.PHONY: install-serverless-operator
156+
## Install the Serverless Operator
157+
install-serverless-operator: install-serverless-operator-source install-serverless-operator-subscription
158+
159+
.PHONY: uninstall-serverless-operator-source
160+
## Uninstall the Serverless Operator Source
161+
uninstall-serverless-operator-source:
162+
${Q}${EC} uninstall_postgresql_operator_source
163+
164+
.PHONY: uninstall-serverless-operator-subscription
165+
## Uninstall the Serverless Operator Subscription
166+
uninstall-serverless-operator-subscription:
167+
${Q}${EC} uninstall_postgresql_operator_subscription
168+
169+
.PHONY: uninstall-serverless-operator
170+
## Uninstall the Serverless Operator
171+
uninstall-serverless-operator: uninstall-serverless-operator-source uninstall-serverless-operator-subscription
172+
173+
# === Service Mesh Operator ===
174+
175+
.PHONY: install-service-mesh-operator-source
176+
## Install the Service Mesh Operator Source
177+
install-service-mesh-operator-source:
178+
${Q}${EC} install_postgresql_operator_source
179+
180+
.PHONY: install-service-mesh-operator-subscription
181+
## Install the Service Mesh Operator Subscription
182+
install-service-mesh-operator-subscription:
183+
${Q}${EC} install_postgresql_operator_subscription
184+
185+
.PHONY: install-service-mesh-operator
186+
## Install the Service Mesh Operator
187+
install-service-mesh-operator: install-service-mesh-operator-source install-service-mesh-operator-subscription
188+
189+
.PHONY: uninstall-service-mesh-operator-source
190+
## Uninstall the Service Mesh Operator Source
191+
uninstall-service-mesh-operator-source:
192+
${Q}${EC} uninstall_postgresql_operator_source
193+
194+
.PHONY: uninstall-service-mesh-operator-subscription
195+
## Uninstall the Service Mesh Operator Subscription
196+
uninstall-service-mesh-operator-subscription:
197+
${Q}${EC} uninstall_postgresql_operator_subscription
198+
199+
.PHONY: uninstall-service-mesh-operator
200+
## Uninstall the Service Mesh Operator
201+
uninstall-service-mesh-operator: uninstall-service-mesh-operator-source uninstall-service-mesh-operator-subscription
202+
203+
# === Knative Serving (Serverless UI) ===
204+
205+
.PHONY: install-knative-serving
206+
## Install Knative Serving
207+
install-knative-serving:
208+
${Q}${EC} install_knative_serving
209+
210+
.PHONY: uninstall-knative-serving
211+
## Uninstall Knative Serving
212+
uninstall-knative-serving:
213+
${Q}-${EC} uninstall_knative_serving
214+
215+
# === Quarkus Native S2i Buider Image ===
216+
217+
.PHONY: install-quarkus-native-s2i-builder
218+
## Install ubi-quarkus-native-s2i builder
219+
install-quarkus-native-s2i-builder:
220+
${Q}${EC} install_ubi_quarkus_native_s2i_builder_image
221+
222+
## -- Common Application Developer Targets --
223+
224+
.PHONY: create-project
225+
## Create the OpenShift project/namespace
226+
create-project:
227+
${Q}-${EC} create_project
228+
229+
.PHONY: delete-project
230+
## Delete the OpenShift project/namespace
231+
delete-project:
232+
${Q}${EC} delete_project
233+
234+
.PHONY: create-backing-db-instance
235+
## Create the Backing Service DB Operator
236+
create-backing-db-instance:
237+
${Q}${EC} install_postgresql_db_instance
Lines changed: 7 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -1,115 +1,16 @@
1-
# It's necessary to set this because some environments don't link sh -> bash.
2-
SHELL := /bin/bash
3-
4-
#-----------------------------------------------------------------------------
5-
# VERBOSE target
6-
#-----------------------------------------------------------------------------
7-
8-
# When you run make VERBOSE=1 (the default), executed commands will be printed
9-
# before executed. If you run make VERBOSE=2 verbose flags are turned on and
10-
# quiet flags are turned off for various commands. Use V_FLAG in places where
11-
# you can toggle on/off verbosity using -v. Use Q_FLAG in places where you can
12-
# toggle on/off quiet mode using -q. Use S_FLAG where you want to toggle on/off
13-
# silence mode using -s...
14-
VERBOSE ?= 1
15-
Q = @
16-
Q_FLAG = -q
17-
QUIET_FLAG = --quiet
18-
V_FLAG =
19-
VERBOSE_FLAG =
20-
S_FLAG = -s
21-
X_FLAG =
22-
ifeq ($(VERBOSE),1)
23-
Q =
24-
endif
25-
ifeq ($(VERBOSE),2)
26-
Q =
27-
Q_FLAG =
28-
QUIET_FLAG =
29-
S_FLAG =
30-
V_FLAG = -v
31-
VERBOSE_FLAG = --verbose
32-
X_FLAG = -x
33-
endif
34-
35-
361
.DEFAULT_GOAL := help
372

38-
## -- Utility targets --
39-
40-
## Print help message for all Makefile targets
41-
## Run `make` or `make help` to see the help
42-
.PHONY: help
43-
help: ## Credit: https://gist.github.com/prwhite/8168133#gistcomment-2749866
44-
45-
@printf "Usage:\n make <target>";
46-
47-
@awk '{ \
48-
if ($$0 ~ /^.PHONY: [a-zA-Z\-\_0-9]+$$/) { \
49-
helpCommand = substr($$0, index($$0, ":") + 2); \
50-
if (helpMessage) { \
51-
printf "\033[36m%-20s\033[0m %s\n", \
52-
helpCommand, helpMessage; \
53-
helpMessage = ""; \
54-
} \
55-
} else if ($$0 ~ /^[a-zA-Z\-\_0-9.]+:/) { \
56-
helpCommand = substr($$0, 0, index($$0, ":")); \
57-
if (helpMessage) { \
58-
printf "\033[36m%-20s\033[0m %s\n", \
59-
helpCommand, helpMessage; \
60-
helpMessage = ""; \
61-
} \
62-
} else if ($$0 ~ /^##/) { \
63-
if (helpMessage) { \
64-
helpMessage = helpMessage"\n "substr($$0, 3); \
65-
} else { \
66-
helpMessage = substr($$0, 3); \
67-
} \
68-
} else { \
69-
if (helpMessage) { \
70-
print "\n "helpMessage"\n" \
71-
} \
72-
helpMessage = ""; \
73-
} \
74-
}' \
75-
$(MAKEFILE_LIST)
76-
77-
## -- Cluster Admin targets --
78-
79-
.PHONY: install-service-binding-operator-source
80-
## Install the Service Binding Operator
81-
install-service-binding-operator-source:
82-
@oc apply -f service-binding-operator-source.yaml
83-
84-
.PHONY: install-backing-db-operator-source
85-
## Install the Backing Service DB Operator
86-
install-backing-db-operator-source:
87-
@oc apply -f backing-db-operator-source.yaml
3+
include ../commons.mk
884

895
## -- Application Developer targets --
906

91-
.PHONY: create-project
92-
## Create the OpenShift project/namespace
93-
create-project:
94-
@oc new-project service-binding-demo
95-
96-
.PHONY: create-backing-db-instance
97-
## Create the Backing Service Database
98-
create-backing-db-instance:
99-
@oc apply -f create-db-instance.yaml
100-
101-
.PHONY: create-service-binding-request
102-
## Create the Service Binding Request
103-
create-service-binding-request:
104-
@oc apply -f service-binding-request.yaml
105-
1067
.PHONY: set-labels-on-java-app
1078
## Set the binding labels for the app
1089
set-labels-on-java-app:
109-
@oc project service-binding-demo
110-
@oc patch dc java-app -p '{"metadata": {"labels": {"connects-to": "postgres", "environment": "demo"}}}'
10+
${Q}oc project service-binding-demo
11+
${Q}oc patch dc java-app -p '{"metadata": {"labels": {"connects-to": "postgres", "environment": "demo"}}}'
11112

112-
.PHONY: delete-project
113-
## Delete the OpenShift project/namespace
114-
delete-project:
115-
@-oc delete project service-binding-demo
13+
.PHONY: create-service-binding-request
14+
## Create the Service Binding Request
15+
create-service-binding-request:
16+
${Q}oc apply -f service-binding-request.yaml

examples/java_postgresql_customvar/backing-db-operator-source.yaml

Lines changed: 0 additions & 10 deletions
This file was deleted.

examples/java_postgresql_customvar/create-db-instance.yaml

Lines changed: 0 additions & 10 deletions
This file was deleted.

examples/java_postgresql_customvar/namespace.yaml

Lines changed: 0 additions & 5 deletions
This file was deleted.

examples/java_postgresql_customvar/service-binding-operator-source.yaml

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)