-
Notifications
You must be signed in to change notification settings - Fork 35
/
Makefile
82 lines (71 loc) · 4.61 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
# Project Setup
PROJECT_NAME := wordpress-operator
PROJECT_REPO := github.com/bitpoke/$(PROJECT_NAME)
PLATFORMS = linux_amd64 darwin_amd64
include build/makelib/common.mk
GO111MODULE=on
GO_STATIC_PACKAGES = $(GO_PROJECT)/cmd/wordpress-operator
GO_SUPPORTED_VERSIONS = 1.17
GOFMT_VERSION = 1.17
GOLANGCI_LINT_VERSION = 1.42.1
GO_LDFLAGS += -X github.com/bitpoke/wordpress-operator/pkg/version.buildDate=$(BUILD_DATE) \
-X github.com/bitpoke/wordpress-operator/pkg/version.gitVersion=$(VERSION) \
-X github.com/bitpoke/wordpress-operator/pkg/version.gitCommit=$(GIT_COMMIT) \
-X github.com/bitpoke/wordpress-operator/pkg/version.gitTreeState=$(GIT_TREE_STATE)
include build/makelib/golang.mk
DOCKER_REGISTRY ?= docker.io/bitpoke
IMAGES ?= wordpress-operator
include build/makelib/image.mk
KUBEBUILDER_ASSETS_VERSION := 1.21.2
GEN_CRD_OPTIONS := crd:crdVersions=v1,preserveUnknownFields=false
include build/makelib/kubebuilder-v3.mk
# fix for https://github.com/kubernetes-sigs/controller-tools/issues/476
.PHONY: .kubebuilder.fix-preserve-unknown-fields
.kubebuilder.fix-preserve-unknown-fields:
@for crd in $(wildcard $(CRD_DIR)/*.yaml) ; do \
$(YQ) e '.spec.preserveUnknownFields=false' -i "$${crd}" ;\
done
.kubebuilder.manifests.done: .kubebuilder.fix-preserve-unknown-fields
include build/makelib/helm.mk
.PHONY: .kubebuilder.update.chart
.kubebuilder.update.chart: kubebuilder.manifests $(YQ)
@$(INFO) updating helm RBAC and CRDs from kubebuilder manifests
@rm -rf $(HELM_CHARTS_DIR)/wordpress-operator/crds
@mkdir -p $(HELM_CHARTS_DIR)/wordpress-operator/crds
@set -e; \
for crd in $(wildcard $(CRD_DIR)/*.yaml) ; do \
cp $${crd} $(HELM_CHARTS_DIR)/wordpress-operator/crds/ ; \
$(YQ) e '.metadata.labels["app.kubernetes.io/name"]="wordpress-operator"' -i $(HELM_CHARTS_DIR)/wordpress-operator/crds/$$(basename $${crd}) ; \
$(YQ) e 'del(.metadata.creationTimestamp)' -i $(HELM_CHARTS_DIR)/wordpress-operator/crds/$$(basename $${crd}) ; \
$(YQ) e 'del(.status)' -i $(HELM_CHARTS_DIR)/wordpress-operator/crds/$$(basename $${crd}) ; \
done
@echo '{{- if .Values.rbac.create }}' > $(HELM_CHARTS_DIR)/wordpress-operator/templates/clusterrole.yaml
@echo 'apiVersion: rbac.authorization.k8s.io/v1' >> $(HELM_CHARTS_DIR)/wordpress-operator/templates/clusterrole.yaml
@echo 'kind: ClusterRole' >> $(HELM_CHARTS_DIR)/wordpress-operator/templates/clusterrole.yaml
@echo 'metadata:' >> $(HELM_CHARTS_DIR)/wordpress-operator/templates/clusterrole.yaml
@echo ' name: {{ include "wordpress-operator.fullname" . }}' >> $(HELM_CHARTS_DIR)/wordpress-operator/templates/clusterrole.yaml
@echo ' labels:' >> $(HELM_CHARTS_DIR)/wordpress-operator/templates/clusterrole.yaml
@echo ' {{- include "wordpress-operator.labels" . | nindent 4 }}' >> $(HELM_CHARTS_DIR)/wordpress-operator/templates/clusterrole.yaml
@echo 'rules:' >> $(HELM_CHARTS_DIR)/wordpress-operator/templates/clusterrole.yaml
@yq e -P '.rules' config/rbac/role.yaml >> $(HELM_CHARTS_DIR)/wordpress-operator/templates/clusterrole.yaml
@echo '{{- end }}' >> $(HELM_CHARTS_DIR)/wordpress-operator/templates/clusterrole.yaml
@$(OK) updating helm RBAC and CRDs from kubebuilder manifests
.generate.run: .kubebuilder.update.chart
.PHONY: .helm.publish
.helm.publish:
@$(INFO) publishing helm charts
@rm -rf $(WORK_DIR)/charts
@git clone -q [email protected]:bitpoke/helm-charts.git $(WORK_DIR)/charts
@cp $(HELM_OUTPUT_DIR)/*.tgz $(WORK_DIR)/charts/docs/
@git -C $(WORK_DIR)/charts add $(WORK_DIR)/charts/docs/*.tgz
@git -C $(WORK_DIR)/charts commit -q -m "Added $(call list-join,$(COMMA)$(SPACE),$(foreach c,$(HELM_CHARTS),$(c)-v$(HELM_CHART_VERSION)))"
@git -C $(WORK_DIR)/charts push -q
@$(OK) publishing helm charts
.publish.run: .helm.publish
.PHONY: .helm.package.prepare.wordpress-operator
.helm.package.prepare.wordpress-operator: $(YQ)
@$(INFO) prepare wordpress-operator chart $(HELM_CHART_VERSION)
@$(YQ) e '.image.repository="$(DOCKER_REGISTRY)/wordpress-operator"' -i $(HELM_CHARTS_WORK_DIR)/wordpress-operator/values.yaml
@$(SED) 's/:latest/:$(IMAGE_TAG)/g' $(HELM_CHARTS_WORK_DIR)/wordpress-operator/Chart.yaml
@$(OK) prepare wordpress-operator chart $(HELM_CHART_VERSION)
.helm.package.run.wordpress-operator: .helm.package.prepare.wordpress-operator