Skip to content

Commit a9c0f2c

Browse files
committed
Revert "rewrite operator scaffolding, metrics, and controller coverage"
This reverts commit 547f7c3. Reason: Wrong branch, should use PR first.
1 parent 547f7c3 commit a9c0f2c

40 files changed

+1447
-2828
lines changed

.github/workflows/pull_request_coverage.yaml

Lines changed: 0 additions & 17 deletions
This file was deleted.

.github/workflows/test.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Check Coverage
2+
on:
3+
push:
4+
branches:
5+
- "master"
6+
pull_request:
7+
branches:
8+
- "master"
9+
10+
jobs:
11+
code_coverage:
12+
name: "Code Coverage"
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v5
17+
- name: Set up Go
18+
uses: actions/setup-go@v6
19+
with:
20+
go-version: 1.25.0
21+
22+
- name: Verify code
23+
id: verify
24+
uses: stakater/.github/.github/actions/operator/verify@main
25+
with:
26+
ENABLE_LINTING: false
27+
ENABLE_UNIT_TESTS: true
28+
29+
- name: Check Code Coverage
30+
id: coverage
31+
uses: stakater/.github/.github/actions/operator/coverage@feature/code-coverage
32+
#uses: stakater/.github/.github/workflows/pull_request_coverage.yaml@feature/code-coverage
33+
with:
34+
TARGET_BRANCH: master
35+
env:
36+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

DEPLOY.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ For local development and testing, you can build and push the operator image dir
1313
3. Add a version entry to `catalog/channels.yaml` following OLM upgrade specifications:
1414
```yaml
1515
entries:
16-
- name: expiring-secret-operator.v0.0.1
17-
- name: expiring-secret-operator.v0.0.2 # This is the next version to be released
16+
- name: expiring-secrets.v0.0.1
17+
- name: expiring-secrets.v0.0.2 # This is the next version to be released
1818
skips:
19-
- expiring-secret-operator.v0.0.1
19+
- expiring-secrets.v0.0.1
2020
```
2121
4. Render, build, and push the catalog index:
2222
```sh
@@ -33,10 +33,10 @@ A catalog release is triggered if:
3333
- A new version entry is specified in `catalog/channels.yaml,` indicating the upcoming release.
3434
```yaml
3535
entries:
36-
- name: expiring-secret-operator.v0.0.1
37-
- name: expiring-secret-operator.v0.0.2 # This is the next version to be released
36+
- name: expiring-secrets.v0.0.1
37+
- name: expiring-secrets.v0.0.2 # This is the next version to be released
3838
skips:
39-
- expiring-secret-operator.v0.0.1
39+
- expiring-secrets.v0.0.1
4040
```
4141
4242
## Working with Entries in `catalog/channels.yaml`
@@ -61,29 +61,29 @@ Example:
6161

6262
```yaml
6363
entries:
64-
- name: expiring-secret-operator.v0.0.3
64+
- name: expiring-secrets.v0.0.3
6565
skips:
66-
- expiring-secret-operator.v0.0.1
67-
- expiring-secret-operator.v0.0.2
66+
- expiring-secrets.v0.0.1
67+
- expiring-secrets.v0.0.2
6868
```
6969
#### Breaking API Changes (Use replaces)
7070
For breaking API changes, the replaces field is used to specify which previous version is being replaced. This indicates to OLM that the older version should be upgraded to the new version.
7171
Example:
7272

7373
```yaml
7474
entries:
75-
- name: expiring-secret-operator.v0.0.3
76-
replaces: expiring-secret-operator.v0.0.1
75+
- name: expiring-secrets.v0.0.3
76+
replaces: expiring-secrets.v0.0.1
7777
```
7878

7979
## Contributing
8080
1. Add the next version entry in `catalog/channels.yaml`:
8181
```yaml
8282
entries:
83-
- name: expiring-secret-operator.v{{CURRENT}}
84-
- name: expiring-secret-operator.v{{NEXT}}
83+
- name: expiring-secrets.v{{CURRENT}}
84+
- name: expiring-secrets.v{{NEXT}}
8585
skips:
86-
- expiring-secret-operator.v0.0.1
86+
- expiring-secrets.v0.0.1
8787
```
8888
2. Create a PR and run tests.
8989
3. Merging the PR will trigger the build and push the releases.

Makefile

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
VERSION ?= 0.0.1
2-
OPERATOR_NAME ?= expiring-secret-operator
3-
#OPERATOR_NAME ?= expiring-secrets
2+
OPERATOR_NAME ?= expiring-secrets
43
PROJECT_NAME ?= expiring-secrets.stakater.com
5-
#vimTEST_CLUSTER_NAME ?= kind
6-
#DOCKER_REPO_NAME ?= expiring-secret-operator
4+
TEST_CLUSTER_NAME ?= kind
5+
DOCKER_REPO_NAME ?= expiring-secret-operator
76
#SUPPRESS_OUTPUT ?= false
87

98
TEST_ARGS ?= -v -test.v -ginkgo.v
@@ -14,22 +13,4 @@ TEST_ARGS ?= -v -test.v -ginkgo.v
1413
.PHONY: pre-commit
1514
pre-commit: precheck check_license fmt vet lint
1615

17-
.PHONY: e2e
18-
e2e: undeploy gh-action test-e2e
19-
20-
.PHONY: gh-action
21-
gh-action:
22-
# @{ \
23-
# $(MAKE) manifests build docker-build; \
24-
# $(MAKE) bundle bundle-build; \
25-
# $(MAKE) docker-build bundle-build ; \
26-
# $(MAKE) catalog-render catalog-build; \
27-
# $(MAKE) deploy; \
28-
# };
29-
@{ \
30-
$(MAKE) manifests build docker-build; \
31-
$(MAKE) bundle bundle-build; \
32-
$(MAKE) deploy; \
33-
}
34-
3516
include Makefile.common

Makefile.common

Lines changed: 19 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -272,27 +272,15 @@ common-test-e2e-dev: ## Run e2e tests locally with guaranteed cleanup even on fa
272272
$(MAKE) test-e2e; \
273273
exit_code=$$?; \
274274
if [ $$exit_code -ne 0 ]; then \
275-
$(MAKE) get-pod-logs; \
275+
kubectl logs deploy/$(OPERATOR_NAME)-controller-manager -n $(OPERATOR_NS); \
276276
fi; \
277277
echo "Cleaning up..."; \
278278
$(MAKE) post-e2e-test; \
279279
exit $$exit_code; \
280280
}
281281

282-
# This target is used to print the logs of the operator's pod(s) in the test cluster,
283-
# which can be helpful for debugging failed e2e tests.
284-
.PHONY: common-get-pod-logs
285-
common-get-pod-logs:
286-
@{ \
287-
echo "$(FG_BLUE)>> $(FG_GREEN)---- Pod logs (last 50 lines, if any) ----$(RESET)"; \
288-
for p in $$( $(KUBECTL) -n "$$ns" get pods -l control-plane=controller-manager -o name 2>/dev/null ); do \
289-
echo "$(FG_BLUE)>> $(FG_GREEN)-- $$p --$(RESET)"; \
290-
kubectl logs "$$p" -n $(OPERATOR_NS) --tail=50 2>/dev/null || true; \
291-
done; \
292-
}
293-
294282
.PHONY: common-test-scorecard
295-
common-test-scorecard: operator-sdk cluster bundle ## Run operator-sdk scorecard tests.
283+
common-test-scorecard: cluster bundle ## Run operator-sdk scorecard tests.
296284
@echo "$(FG_BLUE)>> $(FG_GREEN)running operator-sdk scorecard$(RESET)"
297285
@failed_tests=$$($(OPERATOR_SDK) scorecard bundle \
298286
-c bundle/tests/scorecard/config.yaml --output json | \
@@ -323,6 +311,7 @@ common-lint-fix: golangci-lint ## Run golangci-lint linter and perform fixes
323311
.PHONY: common-pre-e2e-test
324312
common-pre-e2e-test: kustomize docker-build
325313
@echo "$(FG_BLUE)>> $(FG_GREEN)Installing CRDs and deploying operator...$(RESET)"
314+
$(MAKE) install
326315
$(MAKE) deploy
327316

328317
# Uninstall dependencies and undeploy operator after e2e tests.
@@ -454,16 +443,16 @@ common-docker-buildx: ## Build and push docker image for the manager for cross-p
454443
rm -f "$$tmp"
455444

456445
.PHONY: common-build-installer
457-
458446
common-build-installer: manifests generate kustomize ## Generate a consolidated YAML with CRDs and deployment.
459447
@echo "$(FG_BLUE)>> $(FG_GREEN)building installer manifests$(RESET)"
460448
mkdir -p dist
461449
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
462450
$(KUSTOMIZE) build config/default > dist/install.yaml
463451

464452
.PHONY: common-cluster
465-
common-cluster: setup-cluster ## Setup Kind cluster with specified action (default: cluster). Usage: make cluster ACTION=<action>
453+
common-cluster: ## Setup Kind cluster with specified action (default: cluster). Usage: make cluster ACTION=<action>
466454
@echo "$(FG_BLUE)>> $(FG_GREEN)setting up Kind cluster with action '$(ACTION)'$(RESET)"
455+
curl -sSL https://raw.githubusercontent.com/stakater/.github/refs/heads/main/.github/scripts/setup-kind-cluster.sh | \
467456
TEST_CLUSTER_NAME=$(TEST_CLUSTER_NAME) \
468457
IMG=$(IMG) \
469458
CONTAINER_TOOL=$(CONTAINER_TOOL) \
@@ -474,7 +463,7 @@ common-cluster: setup-cluster ## Setup Kind cluster with specified action (defau
474463
PULL_SECRET_NAME=$(PULL_SECRET_NAME) \
475464
GHCR_USERNAME=$(GHCR_USERNAME) \
476465
GHCR_TOKEN=$(GHCR_TOKEN) \
477-
bash $(SETUP_CLUSTER) $(ACTION)
466+
bash -s $(ACTION)
478467

479468

480469
.PHONY: common-load-image
@@ -802,69 +791,34 @@ fi \
802791
}
803792
endef
804793

805-
806-
# fetch-script will fetch anything and make it executable, if it doesn't exist
807-
# $1 - url which can be called
808-
# $2 - local path to save the file
809-
define fetch-script
810-
{ \
811-
set -e; \
812-
if [ ! -f "$(2)" ]; then \
813-
echo "$(FG_BLUE)>> $(FG_GREEN)Fetching: $(2)$(RESET)" ; \
814-
curl -sSLo $(2) "$(1)" ;\
815-
chmod +x $(2) ;\
816-
fi \
817-
}
818-
endef
819-
820-
821-
.PHONY: common-setup-cluster
822-
SETUP_CLUSTER ?= $(LOCALBIN)/setup-kind-cluster.sh
823-
common-setup-cluster: ## Download setup-cluster.sh locally if necessary.
824-
ifeq (,$(wildcard $(SETUP_CLUSTER)))
825-
ifeq (, $(shell which setup-kind-cluster.sh 2>/dev/null))
826-
$(call fetch-script,https://raw.githubusercontent.com/stakater/.github/refs/heads/main/.github/scripts/setup-kind-cluster.sh,$(SETUP_CLUSTER))
827-
else
828-
SETUP_CLUSTER = $(shell which setup-kind-cluster.sh)
829-
endif
830-
endif
831-
832-
.PHONY: common-generate-catalog-index
833-
# Script to generate catalog index from bundle images.
834-
CATALOG_INDEX_SCRIPT ?= $(LOCALBIN)/generate-catalog-index.sh
835-
common-generate-catalog-index: ## Download generate-catalog-index.sh locally if necessary.
836-
ifeq (,$(wildcard $(CATALOG_INDEX_SCRIPT)))
837-
ifeq (, $(shell which generate-catalog-index.sh 2>/dev/null))
838-
$(call fetch-script,https://raw.githubusercontent.com/stakater/.github/refs/heads/main/.github/scripts/generate-catalog-index.sh,$(CATALOG_INDEX_SCRIPT))
839-
else
840-
CATALOG_INDEX_SCRIPT = $(shell which generate-catalog-index.sh)
841-
endif
842-
endif
843-
844794
.PHONY: common-operator-sdk
845795
OPERATOR_SDK ?= $(LOCALBIN)/operator-sdk
846796
common-operator-sdk: ## Download operator-sdk locally if necessary.
847797
ifeq (,$(wildcard $(OPERATOR_SDK)))
848798
ifeq (, $(shell which operator-sdk 2>/dev/null))
849799
@{ \
800+
set -e ;\
850801
mkdir -p $(dir $(OPERATOR_SDK)) ;\
851802
OS=$(shell go env GOOS) && ARCH=$(shell go env GOARCH) && \
852-
$(call fetch-script,https://github.com/operator-framework/operator-sdk/releases/download/$(OPERATOR_SDK_VERSION)/operator-sdk_$${OS}_$${ARCH},$(OPERATOR_SDK))
803+
curl -sSLo $(OPERATOR_SDK) https://github.com/operator-framework/operator-sdk/releases/download/$(OPERATOR_SDK_VERSION)/operator-sdk_$${OS}_$${ARCH} ;\
804+
chmod +x $(OPERATOR_SDK) ;\
853805
}
854806
else
855807
OPERATOR_SDK = $(shell which operator-sdk)
856808
endif
857809
endif
858810

859811
.PHONY: common-opm
860-
OPM ?= $(LOCALBIN)/opm
812+
OPM = $(LOCALBIN)/opm
861813
common-opm: ## Download opm locally if necessary.
862814
ifeq (,$(wildcard $(OPM)))
863815
ifeq (,$(shell which opm 2>/dev/null))
864816
@{ \
817+
set -e ;\
865818
mkdir -p $(dir $(OPM)) ;\
866819
OS=$(shell go env GOOS) && ARCH=$(shell go env GOARCH) && \
867-
$(call fetch-script,https://github.com/operator-framework/operator-registry/releases/download/$(OPM_VERSION)/$${OS}-$${ARCH}-opm,$(OPM))
820+
curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/$(OPM_VERSION)/$${OS}-$${ARCH}-opm ;\
821+
chmod +x $(OPM) ;\
868822
}
869823
else
870824
OPM = $(shell which opm)
@@ -878,9 +832,11 @@ common-yq:
878832
ifeq (,$(wildcard $(YQ_BIN)))
879833
ifeq (,$(shell which yq 2>/dev/null))
880834
@{ \
835+
set -e ;\
881836
mkdir -p $(dir $(YQ_BIN)) ;\
882837
OS=$(shell go env GOOS) && ARCH=$(shell go env GOARCH) && \
883-
$(call fetch-script,https://github.com/mikefarah/yq/releases/download/$(YQ_VERSION)/yq_$${OS}_$${ARCH},$(YQ_BIN))
838+
curl -sSLo $(YQ_BIN) https://github.com/mikefarah/yq/releases/download/$(YQ_VERSION)/yq_$${OS}-$${ARCH} ;\
839+
chmod +x $(YQ_BIN) ;\
884840
}
885841
else
886842
YQ_BIN = $(shell which yq)
@@ -922,23 +878,17 @@ common-bundle-push: ## Push the bundle image.
922878

923879
# Render bundle to the catalog index.
924880
.PHONY: common-catalog-render
925-
common-catalog-render: opm yq generate-catalog-index ## Render bundle to catalog index.
881+
common-catalog-render: opm yq ## Render bundle to catalog index.
926882
@echo "$(FG_BLUE)>> $(FG_GREEN)Rendering catalog index with bundle images$(RESET)"
927-
PATH="$(LOCALBIN):$$PATH" \
928-
bash -c $(CATALOG_INDEX_SCRIPT) "$(DOCKER_REPO_BASE)" "$(OPERATOR_NAME)" "$(CATALOG_DIR_PATH)" "$(VERSION)" "$(GIT_TAG)"
883+
bash generate-catalog-index.sh $(DOCKER_REPO_BASE) $(OPERATOR_NAME) $(CATALOG_DIR_PATH) $(VERSION) $(GIT_TAG)
929884

930885
# Build a catalog image by adding bundle images to an empty catalog using the operator package manager tool, 'opm'.
931886
# This recipe invokes 'opm' in 'semver' bundle add mode. For more information on add modes, see:
932887
# https://github.com/operator-framework/community-operators/blob/7f1438c/docs/packaging-operator.md#updating-your-existing-operator
933888
.PHONY: common-catalog-build
934889
common-catalog-build: opm ## Build a catalog image.
935890
@echo "$(FG_BLUE)>> $(FG_GREEN)Building catalog image $(CATALOG_IMG) with bundles: $(BUNDLE_IMGS)$(RESET)"
936-
$(OPM) index add \
937-
--container-tool docker \
938-
--mode semver \
939-
--tag $(CATALOG_IMG) \
940-
--bundles $(BUNDLE_IMGS) \
941-
$(FROM_INDEX_OPT)
891+
$(OPM) index add --container-tool docker --mode semver --tag $(CATALOG_IMG) --bundles $(BUNDLE_IMGS) $(FROM_INDEX_OPT)
942892

943893
# Push the catalog image.
944894
.PHONY: common-catalog-push

PROJECT

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ layout:
88
plugins:
99
manifests.sdk.operatorframework.io/v2: {}
1010
scorecard.sdk.operatorframework.io/v2: {}
11-
projectName: expiring-secret-operator
12-
repo: github.com/stakater/expiring-secret-operator
11+
projectName: expiring-secrets
12+
repo: github.com/stakater/expiring-secrets
1313
resources:
1414
- api:
1515
crdVersion: v1
@@ -18,6 +18,6 @@ resources:
1818
domain: stakater.com
1919
group: expiring-secrets
2020
kind: Monitor
21-
path: github.com/stakater/expiring-secret-operator/api/v1alpha1
21+
path: github.com/stakater/expiring-secrets/api/v1alpha1
2222
version: v1alpha1
2323
version: "3"

0 commit comments

Comments
 (0)