Skip to content

Commit 2fa423c

Browse files
author
Mikołaj Świątek
committed
Use a temporary kustomization directory
1 parent 45704bb commit 2fa423c

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

Makefile

+19-8
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ TARGETALLOCATOR_IMG ?= ${IMG_PREFIX}/${TARGETALLOCATOR_IMG_REPO}:$(addprefix v,$
2727
OPERATOROPAMPBRIDGE_IMG_REPO ?= operator-opamp-bridge
2828
OPERATOROPAMPBRIDGE_IMG ?= ${IMG_PREFIX}/${OPERATOROPAMPBRIDGE_IMG_REPO}:$(addprefix v,${VERSION})
2929

30+
# Kustomization directory for local manifests
31+
# Whenever we need to make any changes over the default manifests, we put them here
32+
KUSTOMIZATION_DIR = ./dist
33+
KUSTOMIZATION_BASE = config/default
34+
3035
# Options for 'bundle-build'
3136
ifneq ($(origin CHANNELS), undefined)
3237
BUNDLE_CHANNELS := --channels=$(CHANNELS)
@@ -81,7 +86,7 @@ SED ?= $(shell which gsed 2>/dev/null || which sed)
8186
.PHONY: ensure-generate-is-noop
8287
ensure-generate-is-noop: VERSION=$(OPERATOR_VERSION)
8388
ensure-generate-is-noop: USER=open-telemetry
84-
ensure-generate-is-noop: set-image-controller generate bundle
89+
ensure-generate-is-noop: bundle
8590
@# on make bundle config/manager/kustomization.yaml includes changes, which should be ignored for the below check
8691
@git restore config/manager/kustomization.yaml
8792
@git diff -s --exit-code apis/v1alpha1/zz_generated.*.go || (echo "Build failed: a model has been changed but the generated resources aren't up to date. Run 'make generate' and update your PR." && exit 1)
@@ -124,25 +129,30 @@ uninstall: manifests kustomize
124129

125130
# Set the controller image parameters
126131
.PHONY: set-image-controller
127-
set-image-controller: manifests kustomize
128-
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
132+
set-image-controller: manifests kustomize create-kustomization
133+
cd $(KUSTOMIZATION_DIR) && $(KUSTOMIZE) edit set image controller=${IMG}
129134

130135
# Deploy controller in the current Kubernetes context, configured in ~/.kube/config
131136
.PHONY: deploy
132137
deploy: set-image-controller
133-
$(KUSTOMIZE) build config/default | kubectl apply -f -
138+
$(KUSTOMIZE) build $(KUSTOMIZATION_DIR) | kubectl apply -f -
134139
go run hack/check-operator-ready.go 300
135140

136141
# Undeploy controller in the current Kubernetes context, configured in ~/.kube/config
137142
.PHONY: undeploy
138143
undeploy: set-image-controller
139-
$(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
144+
$(KUSTOMIZE) build $(KUSTOMIZATION_DIR) | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
140145

141146
# Generates the released manifests
142147
.PHONY: release-artifacts
143148
release-artifacts: set-image-controller
144-
mkdir -p dist
145-
$(KUSTOMIZE) build config/default -o dist/opentelemetry-operator.yaml
149+
$(KUSTOMIZE) build $(KUSTOMIZATION_DIR) -o dist/opentelemetry-operator.yaml
150+
151+
.PHONY: create-kustomization
152+
create-kustomization:
153+
mkdir -p $(KUSTOMIZATION_DIR)
154+
rm -f $(KUSTOMIZATION_DIR)/kustomization.yaml
155+
cd $(KUSTOMIZATION_DIR) && $(KUSTOMIZE) create --resources ../$(KUSTOMIZATION_BASE)
146156

147157
# Generate manifests e.g. CRD, RBAC etc.
148158
.PHONY: manifests
@@ -377,9 +387,10 @@ operator-sdk:
377387

378388
# Generate bundle manifests and metadata, then validate generated files.
379389
.PHONY: bundle
390+
bundle: KUSTOMIZATION_BASE = config/manifests
380391
bundle: kustomize operator-sdk manifests set-image-controller
381392
$(OPERATOR_SDK) generate kustomize manifests -q
382-
$(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)
393+
$(KUSTOMIZE) build $(KUSTOMIZATION_DIR) | $(OPERATOR_SDK) generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)
383394
$(OPERATOR_SDK) bundle validate ./bundle
384395
./hack/ignore-createdAt-bundle.sh
385396

0 commit comments

Comments
 (0)