1
- PGO_IMAGE_NAME ?= postgres-operator
2
- PGO_IMAGE_MAINTAINER ?= Crunchy Data
3
- PGO_IMAGE_SUMMARY ?= Crunchy PostgreSQL Operator
4
- PGO_IMAGE_DESCRIPTION ?= $(PGO_IMAGE_SUMMARY )
5
- PGO_IMAGE_URL ?= https://www.crunchydata.com/products/crunchy-postgresql-for-kubernetes
6
- PGO_IMAGE_PREFIX ?= localhost
7
1
8
2
PGMONITOR_DIR ?= hack/tools/pgmonitor
9
3
PGMONITOR_VERSION ?= v5.2.1
10
4
QUERIES_CONFIG_DIR ?= hack/tools/queries
11
5
12
- # Buildah's "build" used to be "bud". Use the alias to be compatible for a while.
13
- BUILDAH_BUILD ?= buildah bud
14
-
6
+ BUILDAH ?= buildah
15
7
GO ?= go
16
- GO_BUILD = $(GO ) build
17
8
GO_TEST ?= $(GO ) test
18
9
19
10
# Ensure modules imported by `postgres-operator` and `controller-gen` are compatible
@@ -25,28 +16,12 @@ ENVTEST ?= $(GO) run sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
25
16
KUTTL ?= $(GO ) run github.com/kudobuilder/kuttl/pkg/kuttlctl/cmd/kubectl-kuttl@latest
26
17
KUTTL_TEST ?= $(KUTTL ) test
27
18
28
-
29
19
# #@ General
30
20
31
- # The help target prints out all targets with their descriptions organized
32
- # beneath their categories. The categories are represented by '##@' and the
33
- # target descriptions by '##'. The awk command is responsible for reading the
34
- # entire set of makefiles included in this invocation, looking for lines of the
35
- # file as xyz: ## something, and then pretty-formatting the target and help. Then,
36
- # if there's a line with ##@ something, that gets pretty-printed as a category.
37
- # More info on the usage of ANSI control characters for terminal formatting:
38
- # https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters
39
- # More info on the awk command:
40
- # http://linuxcommand.org/lc3_adv_awk.php
41
-
42
21
.PHONY : help
43
22
help : # # Display this help.
44
23
@awk ' BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST )
45
24
46
- .PHONY : all
47
- all : # # Build all images
48
- all : build-postgres-operator-image
49
-
50
25
.PHONY : setup
51
26
setup : # # Run Setup needed to build images
52
27
setup : get-pgmonitor
@@ -103,6 +78,7 @@ clean-deprecated: ## Clean deprecated resources
103
78
104
79
105
80
# #@ Deployment
81
+
106
82
.PHONY : createnamespaces
107
83
createnamespaces : # # Create operator and target namespaces
108
84
kubectl apply -k ./config/namespace
@@ -131,7 +107,6 @@ undeploy: ## Undeploy the PostgreSQL Operator
131
107
deploy-dev : # # Deploy the PostgreSQL Operator locally
132
108
deploy-dev : PGO_FEATURE_GATES ?= "AllAlpha=true"
133
109
deploy-dev : get-pgmonitor
134
- deploy-dev : build-postgres-operator
135
110
deploy-dev : createnamespaces
136
111
kubectl apply --server-side -k ./config/dev
137
112
hack/create-kubeconfig.sh postgres-operator pgo
@@ -150,54 +125,22 @@ deploy-dev: createnamespaces
150
125
/RELATED_IMAGE_/ { N; s,.* \( RELATED_[^[:space:]]* \) .* value:[[:space:]]* \( [^[:space:]]* \) ,\1 = " \2" ,; p; }; \
151
126
}' ) \
152
127
$(foreach v,$(filter RELATED_IMAGE_% ,$(.VARIABLES ) ) ,$(v ) ="$($(v ) ) ") \
153
- bin/postgres-operator
154
-
155
- # #@ Build - Binary
156
- .PHONY : build-postgres-operator
157
- build-postgres-operator : # # Build the postgres-operator binary
158
- $(GO_BUILD ) $(\
159
- ) --ldflags ' -X "main.versionString=$(PGO_VERSION)"' $(\
160
- ) --trimpath -o bin/postgres-operator ./cmd/postgres-operator
161
-
162
- # #@ Build - Images
163
- .PHONY : build-postgres-operator-image
164
- build-postgres-operator-image : # # Build the postgres-operator image
165
- build-postgres-operator-image : PGO_IMAGE_REVISION := $(shell git rev-parse HEAD)
166
- build-postgres-operator-image : PGO_IMAGE_TIMESTAMP := $(shell date -u +% FT% TZ)
167
- build-postgres-operator-image : build-postgres-operator
168
- build-postgres-operator-image : build/postgres-operator/Dockerfile
169
- $(if $(shell (echo 'buildah version 1.24'; $(word 1,$(BUILDAH_BUILD ) ) --version) | sort -Vc 2>&1) , \
170
- $(warning WARNING: old buildah does not invalidate its cache for changed labels: \
171
- https://github.com/containers/buildah/issues/3517))
172
- $(if $(IMAGE_TAG ) ,, $(error missing IMAGE_TAG) )
173
- $(strip $(BUILDAH_BUILD ) ) \
174
- --tag $(BUILDAH_TRANSPORT )$(PGO_IMAGE_PREFIX ) /$(PGO_IMAGE_NAME ) :$(IMAGE_TAG ) \
175
- --label name=' $(PGO_IMAGE_NAME)' \
176
- --label build-date=' $(PGO_IMAGE_TIMESTAMP)' \
177
- --label description=' $(PGO_IMAGE_DESCRIPTION)' \
178
- --label maintainer=' $(PGO_IMAGE_MAINTAINER)' \
179
- --label summary=' $(PGO_IMAGE_SUMMARY)' \
180
- --label url=' $(PGO_IMAGE_URL)' \
181
- --label vcs-ref=' $(PGO_IMAGE_REVISION)' \
182
- --label vendor=' $(PGO_IMAGE_MAINTAINER)' \
183
- --label io.k8s.display-name=' $(PGO_IMAGE_NAME)' \
184
- --label io.k8s.description=' $(PGO_IMAGE_DESCRIPTION)' \
185
- --label io.openshift.tags=" postgresql,postgres,sql,nosql,crunchy" \
186
- --annotation org.opencontainers.image.authors=' $(PGO_IMAGE_MAINTAINER)' \
187
- --annotation org.opencontainers.image.vendor=' $(PGO_IMAGE_MAINTAINER)' \
188
- --annotation org.opencontainers.image.created=' $(PGO_IMAGE_TIMESTAMP)' \
189
- --annotation org.opencontainers.image.description=' $(PGO_IMAGE_DESCRIPTION)' \
190
- --annotation org.opencontainers.image.revision=' $(PGO_IMAGE_REVISION)' \
191
- --annotation org.opencontainers.image.title=' $(PGO_IMAGE_SUMMARY)' \
192
- --annotation org.opencontainers.image.url=' $(PGO_IMAGE_URL)' \
193
- $(if $(PGO_VERSION ) ,$(strip \
194
- --label release=' $(PGO_VERSION)' \
195
- --label version=' $(PGO_VERSION)' \
196
- --annotation org.opencontainers.image.version=' $(PGO_VERSION)' \
197
- )) \
198
- --file $< --format docker --layers .
128
+ $(GO ) run ./cmd/postgres-operator
129
+
130
+ # #@ Build
131
+
132
+ .PHONY : build
133
+ build : # # Build a postgres-operator image
134
+ $(BUILDAH ) build --tag localhost/postgres-operator \
135
+ --label org.opencontainers.image.authors=' Crunchy Data' \
136
+ --label org.opencontainers.image.description=' Crunchy PostgreSQL Operator' \
137
+ --label org.opencontainers.image.revision=' $(shell git rev-parse HEAD)' \
138
+ --label org.opencontainers.image.source=' https://github.com/CrunchyData/postgres-operator' \
139
+ --label org.opencontainers.image.title=' Crunchy PostgreSQL Operator' \
140
+ .
199
141
200
142
# #@ Test
143
+
201
144
.PHONY : check
202
145
check : # # Run basic go tests with coverage output
203
146
check : get-pgmonitor
@@ -301,23 +244,3 @@ generate-rbac: ## Generate RBAC
301
244
rbac:roleName=' postgres-operator' \
302
245
paths=' ./cmd/...' paths=' ./internal/...' \
303
246
output:dir=' config/rbac' # {directory}/role.yaml
304
-
305
-
306
- # #@ Release
307
-
308
- .PHONY : license licenses
309
- license : licenses
310
- licenses : # # Aggregate license files
311
- ./bin/license_aggregator.sh ./cmd/...
312
-
313
- .PHONY : release-postgres-operator-image release-postgres-operator-image-labels
314
- release-postgres-operator-image : # # Build the postgres-operator image and all its prerequisites
315
- release-postgres-operator-image : release-postgres-operator-image-labels
316
- release-postgres-operator-image : licenses
317
- release-postgres-operator-image : build-postgres-operator-image
318
- release-postgres-operator-image-labels :
319
- $(if $(PGO_IMAGE_DESCRIPTION ) ,, $(error missing PGO_IMAGE_DESCRIPTION) )
320
- $(if $(PGO_IMAGE_MAINTAINER ) ,, $(error missing PGO_IMAGE_MAINTAINER) )
321
- $(if $(PGO_IMAGE_NAME ) ,, $(error missing PGO_IMAGE_NAME) )
322
- $(if $(PGO_IMAGE_SUMMARY ) ,, $(error missing PGO_IMAGE_SUMMARY) )
323
- $(if $(PGO_VERSION ) ,, $(error missing PGO_VERSION) )
0 commit comments