Skip to content

Commit 97ab881

Browse files
Merge pull request #270 from sebrandon1/quality_of_life
quality-of-life: Improve local development tooling
2 parents baafb49 + 3481329 commit 97ab881

2 files changed

Lines changed: 45 additions & 5 deletions

File tree

Makefile

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ verify-with-container:
173173
verify-deps:
174174
hack/verify-deps.sh
175175

176+
.PHONY: local-run
176177
local-run: build
177178
RELATED_IMAGE_CERT_MANAGER_WEBHOOK=quay.io/jetstack/cert-manager-webhook:$(CERT_MANAGER_VERSION) \
178179
RELATED_IMAGE_CERT_MANAGER_CA_INJECTOR=quay.io/jetstack/cert-manager-cainjector:$(CERT_MANAGER_VERSION) \
@@ -199,28 +200,40 @@ check-tools:
199200
@command -v $(CONTAINER_ENGINE) >/dev/null 2>&1 || { echo "WARNING: $(CONTAINER_ENGINE) is not installed. Please install it to avoid issues."; }
200201
@command -v kubectl >/dev/null 2>&1 || { echo "WARNING: kubectl is not installed. Please install it to avoid issues."; }
201202

203+
.PHONY: build-operator
202204
build-operator: ## Build operator binary, no additional checks or code generation
203205
@GOFLAGS="-mod=vendor" source hack/go-fips.sh && $(GO) build $(GOBUILD_VERSION_ARGS) -o $(BIN)
204206

207+
.PHONY: build
205208
build: check-tools generate fmt vet build-operator ## Build operator binary.
206209

210+
.PHONY: run
207211
run: check-tools manifests generate fmt vet ## Run a controller from your host.
208212
go run $(PACKAGE)
209213

214+
.PHONY: image-build
210215
image-build: check-tools ## Build container image with the operator.
211216
$(CONTAINER_ENGINE) build -t ${IMG} .
212217

218+
.PHONY: image-push
213219
image-push: check-tools ## Push container image with the operator.
214220
$(CONTAINER_ENGINE) push ${IMG} ${CONTAINER_PUSH_ARGS}
215221

216222
##@ Deployment
217223

224+
.PHONY: deploy
218225
deploy: manifests ## Deploy controller to the K8s cluster specified in ~/.kube/config.
226+
@kubectl get namespace cert-manager-operator >/dev/null 2>&1 || { \
227+
echo "Namespace 'cert-manager-operator' does not exist. Creating it..."; \
228+
kubectl create namespace cert-manager-operator; \
229+
}
219230
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
220-
$(KUSTOMIZE) build config/default | kubectl apply -f -
231+
$(KUSTOMIZE) build config/default | kubectl apply -f -
221232

233+
.PHONY: undeploy
222234
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config.
223-
$(KUSTOMIZE) build config/default | kubectl delete -f -
235+
$(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found -f -
236+
kubectl delete namespace cert-manager-operator --ignore-not-found
224237

225238
.PHONY: bundle
226239
bundle: check-tools $(OPERATOR_SDK_BIN) manifests
@@ -246,6 +259,7 @@ index-image-push: check-tools
246259
$(CONTAINER_ENGINE) push ${INDEX_IMG}
247260

248261
OPM=$(BIN_DIR)/opm
262+
.PHONY: opm
249263
opm: ## Download opm locally if necessary.
250264
$(call get-bin,$(OPM),$(BIN_DIR),https://github.com/operator-framework/operator-registry/releases/download/$(OPM_VERSION)/linux-amd64-opm)
251265

@@ -270,15 +284,16 @@ test-e2e: test-e2e-wait-for-stable-state
270284
./test/e2e \
271285
-ginkgo.label-filter=$(E2E_GINKGO_LABEL_FILTER)
272286

287+
.PHONY: test-e2e-wait-for-stable-state
273288
test-e2e-wait-for-stable-state:
274289
@echo "---- Waiting for stable state ----"
275290
# This ensures the test-e2e-debug-cluster is called if a timeout is reached.
276291
oc wait --for=condition=Available=true deployment/cert-manager-cainjector -n cert-manager --timeout=120s || $(MAKE) test-e2e-debug-cluster
277292
oc wait --for=condition=Available=true deployment/cert-manager -n cert-manager --timeout=120s || $(MAKE) test-e2e-debug-cluster
278293
oc wait --for=condition=Available=true deployment/cert-manager-webhook -n cert-manager --timeout=120s || $(MAKE) test-e2e-debug-cluster
279294
@echo "---- /Waiting for stable state ----"
280-
.PHONY: test-e2e-wait-for-stable-state
281295

296+
.PHONY: test-e2e-debug-cluster
282297
test-e2e-debug-cluster:
283298
@echo "---- Debugging the current state ----"
284299
- oc get pod -n cert-manager-operator
@@ -289,11 +304,10 @@ test-e2e-debug-cluster:
289304
- oc get subscriptions --all-namespaces
290305
- oc logs deployment/cert-manager-operator -n cert-manager-operator
291306
@echo "---- /Debugging the current state ----"
292-
.PHONY: test-e2e-debug-cluster
293307

294308
.PHONY: lint
295309
lint:
296-
$(GOLANGCI_LINT) run --config .golangci.yaml
310+
$(GOLANGCI_LINT) run --config .golangci.yaml
297311

298312
$(GOLANGCI_LINT_BIN):
299313
mkdir -p $(BIN_DIR)

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,16 @@ Prepare your environment for the installation commands.
9090
make deploy
9191
```
9292
93+
### Cleaning up the deployment
94+
95+
To remove the Cert Manager Operator and its associated resources from the cluster, run the following command:
96+
97+
```sh
98+
make undeploy
99+
```
100+
101+
This will delete all resources created during the deployment process, including the operator and operand resources.
102+
93103
## Updating resources
94104
95105
Use the following command to update all generated resources:
@@ -131,6 +141,14 @@ cert-manager-crds/certificaterequests.cert-manager.io-crd.yaml
131141
132142
Check the changes in the `bindata/` folder and assert any inconsistencies or errors.
133143
144+
## Running tests locally
145+
146+
To run all unit tests locally, use the following command:
147+
148+
make test
149+
150+
This will execute all unit tests and generate a coverage report (`cover.out`).
151+
134152
## Running e2e tests locally
135153
136154
The testsuite assumes, that Cert Manager Operator has been successfully deployed
@@ -146,6 +164,14 @@ Then, let it run for a few minutes. Once the operands are deployed, just invoke:
146164

147165
make test-e2e
148166

167+
## Linting the code
168+
169+
To ensure the code adheres to the project's linting rules, run:
170+
171+
make lint
172+
173+
This will use `golangci-lint` to check for any linting issues in the codebase.
174+
149175
## Using unsupported config overrides options
150176
151177
It is possible (although not supported) to specify custom settings to each Cert Manager image. In order to do it,

0 commit comments

Comments
 (0)