forked from devfile/registry-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates for operator sdk v1.28 (devfile#45)
* required changes to update operator sdk Signed-off-by: Michael Valdron <[email protected]> * ginkgo v2 migration changes. Signed-off-by: Michael Valdron <[email protected]> * remove extra ENVTEST definition Signed-off-by: Michael Valdron <[email protected]> * dependencies updated to match operator sdk v1.28 requirements Signed-off-by: Michael Valdron <[email protected]> * refactoring controllers package to internal/controller package as part of go/v4 prep changes in operator sdk v1.28 Signed-off-by: Michael Valdron <[email protected]> * bump gcr.io/kubebuilder/kube-rbac-proxy from v0.13.0 to v0.13.1 as part of operator sdk v1.28 changes Signed-off-by: Michael Valdron <[email protected]> * refactoring main.go to cmd/main.go as part of go/v4 prep changes in operator sdk v1.28 Signed-off-by: Michael Valdron <[email protected]> * update header under integration test source Signed-off-by: Michael Valdron <[email protected]> * update go version from 1.18 to 1.19 under ci workflows Signed-off-by: Michael Valdron <[email protected]> * import admissionv1beta1 changed to admissionv1 as part of operator sdk v1.28 changes Signed-off-by: Michael Valdron <[email protected]> * update license header and boilerplate files Signed-off-by: Michael Valdron <[email protected]> * rbac service account role bindings fixed with labels added Signed-off-by: Michael Valdron <[email protected]> * security context for manager container updated. Signed-off-by: Michael Valdron <[email protected]> * recent changes applied to bundle manifests Signed-off-by: Michael Valdron <[email protected]> * service account renamed to fix name prefix issue. Signed-off-by: Michael Valdron <[email protected]> * fixed envtest binary name Signed-off-by: Michael Valdron <[email protected]> * fixed relative path to 'config/crd/bases' under controller test suite Signed-off-by: Michael Valdron <[email protected]> * controller-gen deepcopy source update to header Signed-off-by: Michael Valdron <[email protected]> * fixup docker-buildx rule Signed-off-by: Michael Valdron <[email protected]> * CHANGELOG added Signed-off-by: Michael Valdron <[email protected]> * included change log documenting as part of PR acceptance criteria Signed-off-by: Michael Valdron <[email protected]> * target os is always linux Signed-off-by: Michael Valdron <[email protected]> * sa changed to service-account Signed-off-by: Michael Valdron <[email protected]> * bundle csv update Signed-off-by: Michael Valdron <[email protected]> * go v4 project structure changes reverted. Signed-off-by: Michael Valdron <[email protected]> * restore unset GOFLAGS Signed-off-by: Michael Valdron <[email protected]> * use operator namespace when waiting for operator pod to run for integration test suite Signed-off-by: Michael Valdron <[email protected]> * add registry operator deploy command to openshift integration test script Signed-off-by: Michael Valdron <[email protected]> * add touch command in Makefile to create junit report if does not exist Signed-off-by: Michael Valdron <[email protected]> * add docker-buildx optional step to build and run the operator instruction under CONTRIBUTING.md Signed-off-by: Michael Valdron <[email protected]> * make /tmp/artifacts directory if does not exist before running integration tests Signed-off-by: Michael Valdron <[email protected]> --------- Signed-off-by: Michael Valdron <[email protected]> Signed-off-by: thepetk <[email protected]>
- Loading branch information
1 parent
0d72cfb
commit 04739cf
Showing
55 changed files
with
1,385 additions
and
194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Change Log | ||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](http://keepachangelog.com/) | ||
and this project adheres to [Semantic Versioning](http://semver.org/). | ||
|
||
## [Unreleased] | ||
|
||
### Added | ||
- [devfile/api#1106](https://github.com/devfile/api/issues/1106) | ||
Registry operator should be in sync with operator SDK releases | ||
- Addition of `CHANGELOG.md` | ||
|
||
### Changed | ||
|
||
- [devfile/api#1106](https://github.com/devfile/api/issues/1106) | ||
Registry operator should be in sync with operator SDK releases | ||
- Syncs changes up to operator sdk v1.28 | ||
- [v1.28.0 changes](https://sdk.operatorframework.io/docs/upgrading-sdk-version/v1.28.0/) | ||
- [v1.25.0 changes](https://sdk.operatorframework.io/docs/upgrading-sdk-version/v1.25.0/) | ||
- [v1.23.0 changes](https://sdk.operatorframework.io/docs/upgrading-sdk-version/v1.23.0/) | ||
- [devfile/api#881](https://github.com/devfile/api/issues/881) | ||
Update Ginkgo version in registry operator | ||
|
||
### Fixed | ||
- [devfile/api#1106](https://github.com/devfile/api/issues/1106) | ||
Registry operator should be in sync with operator SDK releases | ||
- Registry operator service account changed from `default` to `service-account` to fix permissions error for creating leader election leases |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,10 @@ BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL) | |
IMG ?= quay.io/devfile/registry-operator:next | ||
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary. | ||
ENVTEST_K8S_VERSION = 1.26 | ||
|
||
# Controller tools version number | ||
CONTROLLER_TOOLS_VERSION ?= v0.9.2 | ||
# Kustomize version number | ||
KUSTOMIZE_VERSION ?= v3.8.7 | ||
|
||
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) | ||
ifeq (,$(shell go env GOBIN)) | ||
|
@@ -67,32 +70,48 @@ all: build | |
help: ## Display this help. | ||
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) | ||
|
||
##@ Build Dependencies | ||
|
||
## Local binary path | ||
LOCALBIN ?= $(shell pwd)/bin | ||
$(LOCALBIN): | ||
mkdir -p $(LOCALBIN) | ||
|
||
## Tool binaries | ||
KUSTOMIZE ?= $(LOCALBIN)/kustomize | ||
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen | ||
ENVTEST ?= $(LOCALBIN)/setup-envtest | ||
|
||
##@ Development | ||
|
||
.PHONY: test | ||
test: manifests generate fmt vet envtest ## Run tests. | ||
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test `go list ./... | grep -v /tests/` -coverprofile cover.out -v | ||
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test -timeout=1h `go list ./... | grep -v /tests/` -coverprofile cover.out -v | ||
|
||
### test-integration: runs integration tests on the cluster set in context. | ||
.PHONY: test-integration | ||
test-integration: | ||
CGO_ENABLED=0 go test -v -c -o bin/devfileregistry-operator-integration ./tests/integration/cmd/devfileregistry_test.go | ||
./bin/devfileregistry-operator-integration | ||
CGO_ENABLED=0 go test -v -c -o $(LOCALBIN)/devfileregistry-operator-integration ./tests/integration/cmd/devfileregistry_test.go | ||
# Create junit report output file if does not exist | ||
mkdir -p /tmp/artifacts && touch /tmp/artifacts/junit-devfileregistry-operator.xml | ||
$(LOCALBIN)/devfileregistry-operator-integration -ginkgo.fail-fast --ginkgo.junit-report=/tmp/artifacts/junit-devfileregistry-operator.xml | ||
|
||
##@ Build | ||
|
||
.PHONY: build | ||
manager: generate fmt vet ## Build manager binary. | ||
go build -o bin/manager main.go | ||
.PHONY: build manager | ||
manager: manifests generate fmt vet ## Build manager binary. | ||
go build -o $(LOCALBIN)/manager ./cmd/main.go | ||
|
||
.PHONY: run | ||
run: manifests generate fmt vet ## Run a controller from your host. | ||
go run ./main.go | ||
go run ./cmd/main.go | ||
|
||
.PHONY: manifests | ||
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects. | ||
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases | ||
|
||
### check_fmt: Checks the formatting on files in repo | ||
.PHONY: check_fmt | ||
check_fmt: | ||
ifeq ($(shell command -v goimports 2> /dev/null),) | ||
$(error "goimports must be installed for this rule" && exit 1) | ||
|
@@ -113,6 +132,7 @@ fmt: ## Run go fmt against code. | |
go fmt ./... | ||
|
||
### fmt_license: ensure license header is set on all files | ||
.PHONY: fmt_license | ||
fmt_license: | ||
ifneq ($(shell command -v addlicense 2> /dev/null),) | ||
@echo 'addlicense -v -f license_header.txt **/*.go' | ||
|
@@ -139,30 +159,39 @@ docker-build: | |
docker-push: | ||
docker push ${IMG} | ||
|
||
# PLATFORMS defines the target platforms for the manager image be build to provide support to multiple | ||
# architectures. (i.e. make docker-buildx IMG=quay.io/devfile/registry-operator:next). To use this option you need to: | ||
# - able to use docker buildx . More info: https://docs.docker.com/build/buildx/ | ||
# - have enable BuildKit, More info: https://docs.docker.com/develop/develop-images/build_enhancements/ | ||
# - be able to push the image for your registry (i.e. if you do not inform a valid value via IMG=quay.io/<user>/registry-operator:next than the export will fail) | ||
# To properly provided solutions that supports more than one platform you should use this option. | ||
# **docker-buildx does not work with podman** | ||
PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le | ||
.PHONY: docker-buildx | ||
docker-buildx: test ## Build and push docker image for the manager for cross-platform support | ||
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile | ||
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross | ||
- docker buildx create --name registry-operator-builder | ||
docker buildx use registry-operator-builder | ||
- docker buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross $(shell pwd) | ||
- docker buildx rm registry-operator-builder | ||
rm Dockerfile.cross | ||
|
||
.PHONY: install-cert | ||
install-cert: ## Install cert manager for webhooks | ||
$(K8S_CLI) apply -f https://github.com/cert-manager/cert-manager/releases/download/$(CERT_MANAGER_VERSION)/cert-manager.yaml | ||
|
||
.PHONY: uninstall-cert | ||
uninstall-cert: | ||
$(K8S_CLI) delete -f https://github.com/cert-manager/cert-manager/releases/download/$(CERT_MANAGER_VERSION)/cert-manager.yaml | ||
|
||
# find or download controller-gen | ||
# download controller-gen if necessary | ||
controller-gen: | ||
ifeq (, $(shell which controller-gen)) | ||
@{ \ | ||
set -e ;\ | ||
CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\ | ||
cd $$CONTROLLER_GEN_TMP_DIR ;\ | ||
go mod init tmp ;\ | ||
GOFLAGS="" go install sigs.k8s.io/controller-tools/cmd/[email protected] ;\ | ||
rm -rf $$CONTROLLER_GEN_TMP_DIR ;\ | ||
} | ||
CONTROLLER_GEN=$(GOBIN)/controller-gen | ||
else | ||
CONTROLLER_GEN=$(shell which controller-gen) | ||
endif | ||
|
||
|
||
.PHONY: controller-gen | ||
controller-gen: $(CONTROLLER_GEN) | ||
$(CONTROLLER_GEN): $(LOCALBIN) | ||
test -s $(LOCALBIN)/controller-gen && $(LOCALBIN)/controller-gen --version | grep -q $(CONTROLLER_TOOLS_VERSION) || \ | ||
GOBIN=$(LOCALBIN) GOFLAGS="" go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION) | ||
|
||
##@ Deployment | ||
|
||
|
@@ -183,41 +212,16 @@ deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in | |
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 | $(K8S_CLI) delete -f - | ||
|
||
KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | ||
.PHONY: kustomize | ||
kustomize: $(KUSTOMIZE) | ||
$(KUSTOMIZE): $(LOCALBIN) | ||
test -s $(LOCALBIN)/kustomize || { curl -s $(KUSTOMIZE_INSTALL_SCRIPT) | bash -s -- $(subst v,,$(KUSTOMIZE_VERSION)) $(LOCALBIN); } | ||
|
||
kustomize: | ||
ifeq (, $(shell which kustomize)) | ||
@{ \ | ||
set -e ;\ | ||
KUSTOMIZE_GEN_TMP_DIR=$$(mktemp -d) ;\ | ||
cd $$KUSTOMIZE_GEN_TMP_DIR ;\ | ||
go mod init tmp ;\ | ||
GOFLAGS="" go install sigs.k8s.io/kustomize/kustomize/[email protected] ;\ | ||
go mod vendor ;\ | ||
rm -rf $$KUSTOMIZE_GEN_TMP_DIR ;\ | ||
} | ||
KUSTOMIZE=$(GOBIN)/kustomize | ||
else | ||
KUSTOMIZE=$(shell which kustomize) | ||
endif | ||
|
||
ENVTEST = $(shell pwd)/bin/setup-envtest | ||
.PHONY: envtest | ||
envtest: ## Download envtest-setup locally if necessary. | ||
$(call go-get-tool,$(ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest@latest) | ||
|
||
# go-get-tool will 'go install' any package $2 and install it to $1. | ||
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST)))) | ||
define go-get-tool | ||
@[ -f $(1) ] || { \ | ||
set -e ;\ | ||
TMP_DIR=$$(mktemp -d) ;\ | ||
cd $$TMP_DIR ;\ | ||
go mod init tmp ;\ | ||
echo "Downloading $(2)" ;\ | ||
GOBIN=$(PROJECT_DIR)/bin go install $(2) ;\ | ||
rm -rf $$TMP_DIR ;\ | ||
} | ||
endef | ||
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary. | ||
$(ENVTEST): $(LOCALBIN) | ||
test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) GOFLAGS="" go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest | ||
|
||
# Generate bundle manifests and metadata, then validate generated files. | ||
.PHONY: bundle | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 0 additions & 5 deletions
5
bundle/manifests/registry-operator-default_v1_serviceaccount.yaml
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.