-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
97 lines (79 loc) · 4.27 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
# Set these to the desired values
ARTIFACT_ID=k8s-dogu-operator
VERSION=2.2.0
IMAGE=cloudogu/${ARTIFACT_ID}:${VERSION}
GOTAG=1.22.5
MAKEFILES_VERSION=9.2.0
LINT_VERSION=v1.57.2
PRE_COMPILE = generate-deepcopy
K8S_COMPONENT_SOURCE_VALUES = ${HELM_SOURCE_DIR}/values.yaml
K8S_COMPONENT_TARGET_VALUES = ${HELM_TARGET_DIR}/values.yaml
CRD_DOGU_SOURCE = ${HELM_CRD_SOURCE_DIR}/templates/k8s.cloudogu.com_dogus.yaml
CRD_RESTART_SOURCE = ${HELM_CRD_SOURCE_DIR}/templates/k8s.cloudogu.com_dogurestarts.yaml
CRD_POST_MANIFEST_TARGETS = crd-add-labels crd-copy-for-go-embedding
HELM_PRE_GENERATE_TARGETS = helm-values-update-image-version
HELM_POST_GENERATE_TARGETS = helm-values-replace-image-repo template-stage template-log-level template-image-pull-policy
IMAGE_IMPORT_TARGET=image-import
CHECK_VAR_TARGETS=check-all-vars
include build/make/variables.mk
include build/make/self-update.mk
include build/make/dependencies-gomod.mk
include build/make/build.mk
include build/make/test-common.mk
include build/make/test-unit.mk
include build/make/static-analysis.mk
include build/make/clean.mk
include build/make/digital-signature.mk
include build/make/k8s-controller.mk
.PHONY: build-boot
build-boot: crd-helm-apply helm-apply kill-operator-pod ## Builds a new version of the dogu and deploys it into the K8s-EcoSystem.
.PHONY: crd-copy-for-go-embedding
crd-copy-for-go-embedding:
@echo "Copy CRD to api/v1/"
@cp ${CRD_DOGU_SOURCE} api/v1/
.PHONY: helm-values-update-image-version
helm-values-update-image-version: $(BINARY_YQ)
@echo "Updating the image version in source value.yaml to ${VERSION}..."
@$(BINARY_YQ) -i e ".controllerManager.image.tag = \"${VERSION}\"" ${K8S_COMPONENT_SOURCE_VALUES}
.PHONY: helm-values-replace-image-repo
helm-values-replace-image-repo: $(BINARY_YQ)
@if [[ ${STAGE} == "development" ]]; then \
echo "Setting dev image repo in target value.yaml!" ;\
$(BINARY_YQ) -i e ".controllerManager.image.repository=\"${IMAGE_DEV}\"" ${K8S_COMPONENT_TARGET_VALUES} ;\
fi
##@ Deployment
.PHONY: template-stage
template-stage: $(BINARY_YQ)
@if [[ ${STAGE} == "development" ]]; then \
echo "Setting STAGE env in deployment to ${STAGE}!" ;\
$(BINARY_YQ) -i e ".controllerManager.env.stage=\"${STAGE}\"" ${K8S_COMPONENT_TARGET_VALUES} ;\
fi
.PHONY: template-log-level
template-log-level: $(BINARY_YQ)
@echo "Setting LOG_LEVEL env in deployment to ${LOG_LEVEL}!"
@$(BINARY_YQ) -i e ".controllerManager.env.logLevel=\"${LOG_LEVEL}\"" ${K8S_COMPONENT_TARGET_VALUES}
.PHONY: template-image-pull-policy
template-image-pull-policy: $(BINARY_YQ)
@if [[ ${STAGE} == "development" ]]; then \
echo "Setting PULL POLICY to always!" ;\
$(BINARY_YQ) -i e ".controllerManager.imagePullPolicy=\"Always\"" ${K8S_COMPONENT_TARGET_VALUES} ;\
fi
.PHONY: kill-operator-pod
kill-operator-pod:
@echo "Restarting k8s-dogu-operator!"
@kubectl -n ${NAMESPACE} delete pods -l 'app.kubernetes.io/name=${ARTIFACT_ID}'
##@ Debug
.PHONY: print-debug-info
print-debug-info: ## Generates info and the list of environment variables required to start the operator in debug mode.
@echo "The target generates a list of env variables required to start the operator in debug mode. These can be pasted directly into the 'go build' run configuration in IntelliJ to run and debug the operator on-demand."
@echo "STAGE=$(STAGE);LOG_LEVEL=$(LOG_LEVEL);KUBECONFIG=$(KUBECONFIG);NAMESPACE=$(NAMESPACE);DOGU_REGISTRY_ENDPOINT=$(DOGU_REGISTRY_ENDPOINT);DOGU_REGISTRY_USERNAME=$(DOGU_REGISTRY_USERNAME);DOGU_REGISTRY_PASSWORD=$(DOGU_REGISTRY_PASSWORD);DOCKER_REGISTRY={\"auths\":{\"$(docker_registry_server)\":{\"username\":\"$(docker_registry_username)\",\"password\":\"$(docker_registry_password)\",\"email\":\"ignore@me.com\",\"auth\":\"ignoreMe\"}}}"
##@ Mockery
MOCKERY_BIN=${UTILITY_BIN_PATH}/mockery
MOCKERY_VERSION=v2.20.0
${MOCKERY_BIN}: ${UTILITY_BIN_PATH}
$(call go-get-tool,$(MOCKERY_BIN),github.com/vektra/mockery/v2@$(MOCKERY_VERSION))
mocks: ${MOCKERY_BIN} ## Generate all mocks for the dogu operator.
# Mockery respects .mockery.yaml in the project root
@${MOCKERY_BIN} --output internal/cloudogu/mocks --srcpkg github.com/cloudogu/k8s-dogu-operator/internal/cloudogu --all
@${MOCKERY_BIN} --output internal/thirdParty/mocks --srcpkg github.com/cloudogu/k8s-dogu-operator/internal/thirdParty --all
@echo "Mocks successfully created."