Skip to content

Commit

Permalink
Makefile: generate config/manager/kustomization.yaml (#728)
Browse files Browse the repository at this point in the history
There is a modification, `kustomize edit` of this file on deploy and
bundle targets. Since the file is stored in the version control it
pollutes `git status` and `git commit -a`.

Store only "template" in the VCS and generate the file at the build
time.

Move it to a separate target to not repeat yourself.

It will check the target for more other targets than before, but it
should not make any harm.

Make it phony to generate the file every time for the case of
changing IMG variable.

Signed-off-by: Yauheni Kaliuta <ykaliuta@redhat.com>
  • Loading branch information
ykaliuta committed Jan 30, 2024
1 parent c1245ec commit e86c929
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -178,17 +178,26 @@ ifndef ignore-not-found
ignore-not-found = false
endif

.PHONY: prepare
prepare: manifests kustomize manager-kustomization

# phony target for the case of changing IMG variable
.PHONY: manager-kustomization
manager-kustomization: config/manager/kustomization.yaml.in
cd config/manager \
&& cp -f kustomization.yaml.in kustomization.yaml \
&& $(KUSTOMIZE) edit set image controller=$(IMG)

.PHONY: install
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
install: prepare ## Install CRDs into the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/crd | kubectl apply -f -

.PHONY: uninstall
uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
uninstall: prepare ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
$(KUSTOMIZE) build config/crd | kubectl delete --ignore-not-found=$(ignore-not-found) -f -

.PHONY: deploy
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
deploy: prepare ## Deploy controller to the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/default | kubectl apply --namespace $(OPERATOR_NAMESPACE) -f -

.PHONY: undeploy
Expand Down Expand Up @@ -229,9 +238,8 @@ $(GOLANGCI_LINT): $(LOCALBIN)

BUNDLE_DIR ?= "bundle"
.PHONY: bundle
bundle: manifests kustomize operator-sdk ## Generate bundle manifests and metadata, then validate generated files.
bundle: prepare operator-sdk ## Generate bundle manifests and metadata, then validate generated files.
$(OPERATOR_SDK) generate kustomize manifests -q
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
$(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle $(BUNDLE_GEN_FLAGS)
$(OPERATOR_SDK) bundle validate ./$(BUNDLE_DIR)
mv bundle.Dockerfile Dockerfiles/
Expand Down
File renamed without changes.

0 comments on commit e86c929

Please sign in to comment.