Skip to content

Commit

Permalink
setup test suite basics
Browse files Browse the repository at this point in the history
  • Loading branch information
waveywaves committed Feb 23, 2024
1 parent 9c5a639 commit 8d72e2e
Show file tree
Hide file tree
Showing 12 changed files with 583 additions and 39 deletions.
32 changes: 18 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include test/e2e/Makefile

VERSION ?= 1.5.6

# check if we are using MacOS or LINUX and use that to determine the sed command
Expand Down Expand Up @@ -109,10 +107,16 @@ fmt: ## Run go fmt against code.
vet: ## Run go vet against code.
go vet ./...

.PHONY: test
test: manifests generate fmt vet envtest ## Run test.
##@ Test

.PHONY: e2e-test-without-cluster
e2e-test-without-cluster: manifests generate fmt vet envtest ## Run test.
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test ./... -coverprofile cover.out

.PHONY: e2e-test-with-cluster
e2e-test-with-cluster: manifests generate fmt vet envtest ## Run test.
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" ENVTEST_REMOTE=true go test ./... -coverprofile cover.out

##@ Build

.PHONY: build
Expand Down Expand Up @@ -160,28 +164,28 @@ endif

.PHONY: install
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/crd | kubectl apply -f -
$(KUSTOMIZE) build src/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.
$(KUSTOMIZE) build config/crd | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
$(KUSTOMIZE) build src/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}
$(KUSTOMIZE) build config/default | kubectl apply -f -
cd src/config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
$(KUSTOMIZE) build src/config/default | kubectl apply -f -

.PHONY: undeploy
undeploy: ## Undeploy controller 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/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
$(KUSTOMIZE) build src/config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f -

.PHONY: build-helm-chart
build-helm-chart: manifests generate fmt vet kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
# update the crd
$(KUSTOMIZE) build config/crd > chart/templates/uffizziclusters.uffizzi.com_customresourcedefinition.yaml
$(KUSTOMIZE) build src/config/crd > chart/templates/uffizziclusters.uffizzi.com_customresourcedefinition.yaml
$(SED) -i'' -e 's/labels:/labels: {{ include "common.labels.standard" . | nindent 4 }}/' chart/templates/uffizziclusters.uffizzi.com_customresourcedefinition.yaml
# update roles
cp config/rbac/role.yaml chart/templates/manager-role_clusterrole.yaml
cp src/config/rbac/role.yaml chart/templates/manager-role_clusterrole.yaml
$(SED) -i'' -e '/creationTimestamp: null/d' chart/templates/manager-role_clusterrole.yaml
$(SED) -i'' -e 's/name: manager-role/name: {{ include "common.names.fullname" . }}-manager-role/' chart/templates/manager-role_clusterrole.yaml
$(SED) -i'' -e 's/apiVersion: rbac.authorization.k8s.io\/v1/apiVersion: {{ include "common.capabilities.rbac.apiVersion" . }}/' chart/templates/manager-role_clusterrole.yaml
Expand Down Expand Up @@ -230,13 +234,13 @@ $(CONTROLLER_GEN): $(LOCALBIN)
.PHONY: envtest
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
$(ENVTEST): $(LOCALBIN)
test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
@test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest

.PHONY: bundle
bundle: manifests kustomize ## 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)
cd src/config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
$(KUSTOMIZE) build src/config/manifests | operator-sdk generate bundle $(BUNDLE_GEN_FLAGS)
operator-sdk bundle validate ./bundle

.PHONY: bundle-build
Expand Down
2 changes: 1 addition & 1 deletion chart/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ version: 1.5.6
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "v1.5.5"
appVersion: "v1.5.6"
dependencies:
- name: common
repository: https://charts.bitnami.com/bitnami
Expand Down
4 changes: 1 addition & 3 deletions chart/templates/manager-role_clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
apiVersion: {{ include "common.capabilities.rbac.apiVersion" . }}
kind: ClusterRole
metadata:
labels: {{ include "common.labels.standard" . | nindent 4 }}
app.kubernetes.io/component: rbac
app.kubernetes.io/part-of: uffizzi
labels: {{ include "common.labels.standard" . | nindent 4 }} app.kubernetes.io/component: rbac app.kubernetes.io/part-of: uffizzi
name: {{ include "common.names.fullname" . }}-manager-role
rules:
- apiGroups:
Expand Down
2 changes: 1 addition & 1 deletion chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

image:
repository: docker.io/uffizzi/uffizzi-cluster-operator
tag: v1.5.5
tag: v1.5.6
# `flux` dependency values
flux:
helmController:
Expand Down
Loading

0 comments on commit 8d72e2e

Please sign in to comment.