chore(go, operator-skd): update go to 1.20 and operator-sdk to 1.28.0. Be aware: dragons ahead

This commit is contained in:
brokenpip3 2023-05-02 00:28:38 +02:00
parent a690c7cc6c
commit a76d380310
No known key found for this signature in database
GPG Key ID: 1D9BDC803797B4B6
19 changed files with 573 additions and 537 deletions

121
Makefile
View File

@ -124,7 +124,8 @@ endif
cover: ## Runs go test with coverage cover: ## Runs go test with coverage
@echo "" > coverage.txt @echo "" > coverage.txt
@for d in $(PACKAGES); do \ @for d in $(PACKAGES); do \
IMG_RUNNING_TESTS=1 go test -race -coverprofile=profile.out -covermode=atomic "$$d"; \ ENVTEST_K8S_VERSION = 1.26
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" IMG_RUNNING_TESTS=1 go test -race -coverprofile=profile.out -covermode=atomic "$$d"; \
if [ -f profile.out ]; then \ if [ -f profile.out ]; then \
cat profile.out >> coverage.txt; \ cat profile.out >> coverage.txt; \
rm profile.out; \ rm profile.out; \
@ -478,8 +479,9 @@ helm-release-latest: helm
# Download and build hugo extended locally if necessary # Download and build hugo extended locally if necessary
HUGO_PATH = $(shell pwd)/bin/hugo HUGO_PATH = $(shell pwd)/bin/hugo
HUGO_VERSION = v0.62.2 HUGO_VERSION = v0.111.3
HAS_HUGO := $(shell $(HUGO_PATH)/hugo version 2>&- | grep $(HUGO_VERSION)) HAS_HUGO := $(shell $(HUGO_PATH)/hugo version 2>&- | grep $(HUGO_VERSION))
.PHONY: hugo
hugo: hugo:
ifeq ($(HAS_HUGO), ) ifeq ($(HAS_HUGO), )
@echo "Installing Hugo $(HUGO_VERSION)" @echo "Installing Hugo $(HUGO_VERSION)"
@ -502,59 +504,77 @@ run-docs: hugo
##################### FROM OPERATOR SDK ######################## ##################### FROM OPERATOR SDK ########################
# Install CRDs into a cluster # Install CRDs into a cluster
.PHONY: install-crds
install-crds: manifests kustomize install-crds: manifests kustomize
$(KUSTOMIZE) build config/crd | kubectl apply -f - $(KUSTOMIZE) build config/crd | kubectl apply -f -
# Uninstall CRDs from a cluster # Uninstall CRDs from a cluster
ifndef ignore-not-found
ignore-not-found = false
endif
.PHONY: uninstall-crds
uninstall-crds: manifests kustomize uninstall-crds: manifests kustomize
$(KUSTOMIZE) build config/crd | kubectl delete -f - $(KUSTOMIZE) build config/crd | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
# Deploy controller in the configured Kubernetes cluster in ~/.kube/config # Deploy controller in the configured Kubernetes cluster in ~/.kube/config
.PHONY: deploy
deploy: manifests kustomize deploy: manifests kustomize
cd config/manager && $(KUSTOMIZE) edit set image controller=quay.io/$(QUAY_ORGANIZATION)/$(QUAY_REGISTRY):$(GITCOMMIT) cd config/manager && $(KUSTOMIZE) edit set image controller=quay.io/$(QUAY_ORGANIZATION)/$(QUAY_REGISTRY):$(GITCOMMIT)
$(KUSTOMIZE) build config/default | kubectl apply -f - $(KUSTOMIZE) build config/default | kubectl apply -f -
# UnDeploy controller from the configured Kubernetes cluster in ~/.kube/config # UnDeploy controller from the configured Kubernetes cluster in ~/.kube/config
.PHONY: undeploy
undeploy: undeploy:
$(KUSTOMIZE) build config/default | kubectl delete -f - $(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
# Generate manifests e.g. CRD, RBAC etc. # Generate manifests e.g. CRD, RBAC etc.
.PHONY: manifests
manifests: controller-gen manifests: controller-gen
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases $(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
# Generate code # Generate code
.PHONY: generate
generate: controller-gen generate: controller-gen
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..." $(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
# Download controller-gen locally if necessary ##@ Build Dependencies
CONTROLLER_GEN = $(shell pwd)/bin/controller-gen
controller-gen:
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen@v0.4.1)
# Download kustomize locally if necessary ## Location to install dependencies to
KUSTOMIZE = $(shell pwd)/bin/kustomize LOCALBIN ?= $(shell pwd)/bin
kustomize: $(LOCALBIN):
$(call go-get-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/v3@v3.8.7) mkdir -p $(LOCALBIN)
# go-get-tool will 'go get' any package $2 and install it to $1. ## Tool Binaries
define go-get-tool KUSTOMIZE ?= $(LOCALBIN)/kustomize
@[ -f $(1) ] || { \ CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
set -e ;\ ENVTEST ?= $(LOCALBIN)/setup-envtest
TMP_DIR=$$(mktemp -d) ;\
cd $$TMP_DIR ;\ ## Tool Versions
go mod init tmp ;\ KUSTOMIZE_VERSION ?= v3.8.7
echo "Downloading $(2)" ;\ CONTROLLER_TOOLS_VERSION ?= v0.9.2
GOBIN=$(PROJECT_DIR)/bin go get $(2) ;\
rm -rf $$TMP_DIR ;\ KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
} .PHONY: kustomize
endef kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
$(KUSTOMIZE): $(LOCALBIN)
test -s $(LOCALBIN)/kustomize || { curl -s $(KUSTOMIZE_INSTALL_SCRIPT) | bash -s -- $(subst v,,$(KUSTOMIZE_VERSION)) $(LOCALBIN); }
.PHONY: controller-gen
controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary.
$(CONTROLLER_GEN): $(LOCALBIN)
test -s $(LOCALBIN)/controller-gen || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)
.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
.PHONY: operator-sdk .PHONY: operator-sdk
HAS_OPERATOR_SDK := $(shell which $(PROJECT_DIR)/bin/operator-sdk) HAS_OPERATOR_SDK := $(shell which $(PROJECT_DIR)/bin/operator-sdk)
operator-sdk: # Download operator-sdk locally if necessary operator-sdk: # Download operator-sdk locally if necessary
@echo "+ $@" @echo "+ $@"
ifndef HAS_OPERATOR_SDK ifndef HAS_OPERATOR_SDK
wget -O $(PROJECT_DIR)/bin/operator-sdk https://github.com/operator-framework/operator-sdk/releases/download/v1.3.0/operator-sdk_$(PLATFORM)_amd64 wget -O $(PROJECT_DIR)/bin/operator-sdk https://github.com/operator-framework/operator-sdk/releases/download/v${OPERATOR_SDK_VERSION}/operator-sdk_$(PLATFORM)_amd64
chmod +x $(PROJECT_DIR)/bin/operator-sdk chmod +x $(PROJECT_DIR)/bin/operator-sdk
endif endif
@ -563,7 +583,7 @@ endif
bundle: manifests operator-sdk kustomize bundle: manifests operator-sdk kustomize
bin/operator-sdk generate kustomize manifests -q bin/operator-sdk generate kustomize manifests -q
cd config/manager && $(KUSTOMIZE) edit set image controller=quay.io/$(QUAY_ORGANIZATION)/$(QUAY_REGISTRY):$(VERSION_TAG) cd config/manager && $(KUSTOMIZE) edit set image controller=quay.io/$(QUAY_ORGANIZATION)/$(QUAY_REGISTRY):$(VERSION_TAG)
$(KUSTOMIZE) build config/manifests | bin/operator-sdk generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS) $(KUSTOMIZE) build config/manifests | bin/operator-sdk generate bundle $(BUNDLE_GEN_FLAGS)
bin/operator-sdk bundle validate ./bundle bin/operator-sdk bundle validate ./bundle
# Build the bundle image. # Build the bundle image.
@ -572,19 +592,66 @@ bundle-build:
docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) . docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) .
# Download kubebuilder # Download kubebuilder
.PHONY: kubebuilder
kubebuilder: kubebuilder:
mkdir -p ${ENVTEST_ASSETS_DIR} mkdir -p ${ENVTEST_ASSETS_DIR}
test -f ${ENVTEST_ASSETS_DIR}/setup-envtest.sh || curl -sSLo ${ENVTEST_ASSETS_DIR}/setup-envtest.sh https://raw.githubusercontent.com/kubernetes-sigs/controller-runtime/v0.7.0/hack/setup-envtest.sh test -f ${ENVTEST_ASSETS_DIR}/setup-envtest.sh || curl -sSLo ${ENVTEST_ASSETS_DIR}/setup-envtest.sh https://raw.githubusercontent.com/kubernetes-sigs/controller-runtime/v0.7.0/hack/setup-envtest.sh
source ${ENVTEST_ASSETS_DIR}/setup-envtest.sh; fetch_envtest_tools $(ENVTEST_ASSETS_DIR); setup_envtest_env $(ENVTEST_ASSETS_DIR); source ${ENVTEST_ASSETS_DIR}/setup-envtest.sh; fetch_envtest_tools $(ENVTEST_ASSETS_DIR); setup_envtest_env $(ENVTEST_ASSETS_DIR);
# install cert-manager v1.5.1 # install cert-manager v1.5.1
.PHONY: install-cert-manager
install-cert-manager: minikube-start install-cert-manager: minikube-start
kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.5.1/cert-manager.yaml kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.5.1/cert-manager.yaml
.PHONY: uninstall-cert-manager
uninstall-cert-manager: minikube-start uninstall-cert-manager: minikube-start
kubectl delete -f https://github.com/jetstack/cert-manager/releases/download/v1.5.1/cert-manager.yaml kubectl delete -f https://github.com/jetstack/cert-manager/releases/download/v1.5.1/cert-manager.yaml
# Deploy the operator locally along with webhook using helm charts # Deploy the operator locally along with webhook using helm charts
.PHONY: deploy-webhook
deploy-webhook: container-runtime-build-amd64 deploy-webhook: container-runtime-build-amd64
@echo "+ $@" @echo "+ $@"
bin/helm upgrade jenkins chart/jenkins-operator --install --set-string operator.image=${IMAGE_NAME} --set webhook.enabled=true --set jenkins.enabled=false bin/helm upgrade jenkins chart/jenkins-operator --install --set-string operator.image=${IMAGE_NAME} --set webhook.enabled=true --set jenkins.enabled=false
# https://sdk.operatorframework.io/docs/upgrading-sdk-version/v1.6.1/#gov2-gov3-ansiblev1-helmv1-add-opm-and-catalog-build-makefile-targets
.PHONY: opm
OPM = ./bin/opm
opm:
ifeq (,$(wildcard $(OPM)))
ifeq (,$(shell which opm 2>/dev/null))
@{ \
set -e ;\
mkdir -p $(dir $(OPM)) ;\
curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.23.0/$${OS}-$${ARCH}-opm ;\
chmod +x $(OPM) ;\
}
else
OPM = $(shell which opm)
endif
endif
BUNDLE_IMGS ?= $(BUNDLE_IMG)
CATALOG_IMG ?= $(IMAGE_TAG_BASE)-catalog:v$(VERSION) ifneq ($(origin CATALOG_BASE_IMG), undefined) FROM_INDEX_OPT := --from-index $(CATALOG_BASE_IMG) endif
.PHONY: catalog-build
catalog-build: opm
$(OPM) index add --container-tool docker --mode semver --tag $(CATALOG_IMG) --bundles $(BUNDLE_IMGS) $(FROM_INDEX_OPT)
.PHONY: catalog-push
catalog-push: ## Push the catalog image.
$(MAKE) docker-push IMG=$(CATALOG_IMG)
# PLATFORMS defines the target platforms for the manager image be build to provide support to multiple
# architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). 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=<myregistry/image:<tag>> than the export will fail)
# To properly provided solutions that supports more than one platform you should use this option.
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 project-v3-builder
docker buildx use project-v3-builder
- docker buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross
- docker buildx rm project-v3-builder
rm Dockerfile.cross

13
PROJECT
View File

@ -3,12 +3,19 @@ layout: go.kubebuilder.io/v3
projectName: jenkins-operator projectName: jenkins-operator
repo: github.com/jenkinsci/kubernetes-operator repo: github.com/jenkinsci/kubernetes-operator
resources: resources:
- crdVersion: v1 - api:
crdVersion: v1
namespaced: true
# TODO(user): Uncomment the below line if this resource implements a controller, else delete it.
# controller: true
domain: jenkins.io
group: jenkins.io group: jenkins.io
kind: Jenkins kind: Jenkins
path: github.com/jenkinsci/kubernetes-operator/api/v1alpha2
version: v1alpha2 version: v1alpha2
webhookVersion: v1 webhooks:
version: 3-alpha webhookVersion: v1
version: "3"
plugins: plugins:
manifests.sdk.operatorframework.io/v2: {} manifests.sdk.operatorframework.io/v2: {}
scorecard.sdk.operatorframework.io/v2: {} scorecard.sdk.operatorframework.io/v2: {}

View File

@ -58,7 +58,7 @@ func (in *Jenkins) SetupWebhookWithManager(mgr ctrl.Manager) error {
} }
// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation. // TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
// +kubebuilder:webhook:path=/validate-jenkins-io-jenkins-io-v1alpha2-jenkins,mutating=false,failurePolicy=fail,sideEffects=None,groups=jenkins.io.jenkins.io,resources=jenkins,verbs=create;update,versions=v1alpha2,name=vjenkins.kb.io,admissionReviewVersions={v1,v1beta1} // +kubebuilder:webhook:path=/validate-jenkins-io-jenkins-io-v1alpha2-jenkins,mutating=false,failurePolicy=fail,sideEffects=None,groups=jenkins.io.jenkins.io,resources=jenkins,verbs=create;update,versions=v1alpha2,name=vjenkins.kb.io,admissionReviewVersions={v1}
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type // ValidateCreate implements webhook.Validator so a webhook will be registered for the type
func (in *Jenkins) ValidateCreate() error { func (in *Jenkins) ValidateCreate() error {

View File

@ -1,7 +1,7 @@
# Setup variables for the Makefile # Setup variables for the Makefile
NAME=kubernetes-operator NAME=kubernetes-operator
OPERATOR_SDK_VERSION=1.3.0 OPERATOR_SDK_VERSION=1.28.0
GO_VERSION=1.15.6 GO_VERSION=1.20.3
PKG=github.com/jenkinsci/kubernetes-operator PKG=github.com/jenkinsci/kubernetes-operator
QUAY_ORGANIZATION=jenkins-kubernetes-operator QUAY_ORGANIZATION=jenkins-kubernetes-operator
QUAY_REGISTRY=operator QUAY_REGISTRY=operator

View File

@ -28,7 +28,9 @@ patchesStrategicMerge:
# Protect the /metrics endpoint by putting it behind auth. # Protect the /metrics endpoint by putting it behind auth.
# If you want your controller-manager to expose the /metrics # If you want your controller-manager to expose the /metrics
# endpoint w/o any authn/z, please comment the following line. # endpoint w/o any authn/z, please comment the following line.
- manager_auth_proxy_patch.yaml # Mount the controller config file for loading manager configurations
# through a ComponentConfig type
- manager_config_patch.yaml
# Mount the controller config file for loading manager configurations # Mount the controller config file for loading manager configurations
# through a ComponentConfig type # through a ComponentConfig type

View File

@ -10,15 +10,23 @@ spec:
spec: spec:
containers: containers:
- name: kube-rbac-proxy - name: kube-rbac-proxy
image: gcr.io/kubebuilder/kube-rbac-proxy:v0.5.0 image: gcr.io/kubebuilder/kube-rbac-proxy:v0.13.1
args: args:
- "--secure-listen-address=0.0.0.0:8443" - "--secure-listen-address=0.0.0.0:8443"
- "--upstream=http://127.0.0.1:8080/" - "--upstream=http://127.0.0.1:8080/"
- "--logtostderr=true" - "--logtostderr=true"
- "--v=10" - "--v=0"
ports: ports:
- containerPort: 8443 - containerPort: 8443
protocol: TCP
name: https name: https
resources:
limits:
cpu: 500m
memory: 128Mi
requests:
cpu: 5m
memory: 64Mi
- name: manager - name: manager
args: args:
- "--health-probe-bind-address=:8081" - "--health-probe-bind-address=:8081"

View File

@ -14,6 +14,8 @@ spec:
metadata: metadata:
labels: labels:
control-plane: controller-manager control-plane: controller-manager
annotations:
kubectl.kubernetes.io/default-container: manager
spec: spec:
serviceAccountName: jenkins-operator serviceAccountName: jenkins-operator
securityContext: securityContext:
@ -42,8 +44,8 @@ spec:
periodSeconds: 10 periodSeconds: 10
resources: resources:
limits: limits:
cpu: 100m cpu: 200m
memory: 30Mi memory: 100Mi
requests: requests:
cpu: 100m cpu: 100m
memory: 20Mi memory: 20Mi
@ -52,4 +54,5 @@ spec:
valueFrom: valueFrom:
fieldRef: fieldRef:
fieldPath: metadata.namespace fieldPath: metadata.namespace
serviceAccountName: controller-manager
terminationGracePeriodSeconds: 10 terminationGracePeriodSeconds: 10

View File

@ -1,4 +1,3 @@
# Prometheus Monitor Service (Metrics) # Prometheus Monitor Service (Metrics)
apiVersion: monitoring.coreos.com/v1 apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor kind: ServiceMonitor
@ -11,6 +10,10 @@ spec:
endpoints: endpoints:
- path: /metrics - path: /metrics
port: https port: https
scheme: https
bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
tlsConfig:
insecureSkipVerify: true
selector: selector:
matchLabels: matchLabels:
control-plane: controller-manager control-plane: controller-manager

View File

@ -8,5 +8,5 @@ roleRef:
name: proxy-role name: proxy-role
subjects: subjects:
- kind: ServiceAccount - kind: ServiceAccount
name: default name: controller-manager
namespace: default namespace: default

View File

@ -9,6 +9,7 @@ spec:
ports: ports:
- name: https - name: https
port: 8443 port: 8443
protocol: TCP
targetPort: https targetPort: https
selector: selector:
control-plane: controller-manager control-plane: controller-manager

View File

@ -10,3 +10,4 @@ resources:
- auth_proxy_role.yaml - auth_proxy_role.yaml
- auth_proxy_role_binding.yaml - auth_proxy_role_binding.yaml
- auth_proxy_client_clusterrole.yaml - auth_proxy_client_clusterrole.yaml
- service_account.yaml

View File

@ -7,9 +7,19 @@ metadata:
rules: rules:
- apiGroups: - apiGroups:
- "" - ""
- coordination.k8s.io
resources: resources:
- configmaps - configmaps
verbs:
- get
- list
- watch
- create
- update
- patch
- delete
- apiGroups:
- coordination.k8s.io
resources:
- leases - leases
verbs: verbs:
- get - get

View File

@ -0,0 +1,5 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: controller-manager
namespace: system

View File

@ -7,6 +7,7 @@ metadata:
spec: spec:
ports: ports:
- port: 443 - port: 443
protocol: TCP
targetPort: 9443 targetPort: 9443
selector: selector:
control-plane: controller-manager control-plane: controller-manager

117
go.mod
View File

@ -1,31 +1,104 @@
module github.com/jenkinsci/kubernetes-operator module github.com/jenkinsci/kubernetes-operator
go 1.15 go 1.20
require ( require (
github.com/bndr/gojenkins v1.0.1 github.com/bndr/gojenkins v1.1.0
github.com/docker/distribution v2.7.1+incompatible github.com/docker/distribution v2.8.1+incompatible
github.com/emersion/go-smtp v0.11.2 github.com/emersion/go-smtp v0.16.0
github.com/go-logr/logr v0.3.0 github.com/go-logr/logr v1.2.4
github.com/go-logr/zapr v0.2.0 github.com/go-logr/zapr v1.2.3
github.com/golang/mock v1.4.1 github.com/golang/mock v1.6.0
github.com/mailgun/mailgun-go/v3 v3.6.4 github.com/mailgun/mailgun-go/v3 v3.6.4
github.com/onsi/ginkgo v1.14.1 github.com/onsi/ginkgo v1.16.5
github.com/onsi/gomega v1.10.2 github.com/onsi/ginkgo/v2 v2.7.0
github.com/opencontainers/go-digest v1.0.0 // indirect github.com/onsi/gomega v1.24.2
github.com/openshift/api v3.9.0+incompatible github.com/openshift/api v3.9.0+incompatible
github.com/pkg/errors v0.9.1 github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.6.1 github.com/stretchr/testify v1.8.0
go.uber.org/zap v1.15.0 go.uber.org/zap v1.24.0
golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0 golang.org/x/crypto v0.1.0
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect golang.org/x/mod v0.7.0
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
k8s.io/api v0.20.2 k8s.io/api v0.26.2
k8s.io/apimachinery v0.20.2 k8s.io/apimachinery v0.26.2
k8s.io/cli-runtime v0.20.2 k8s.io/cli-runtime v0.26.2
k8s.io/client-go v0.20.2 k8s.io/client-go v0.26.2
k8s.io/utils v0.0.0-20201110183641-67b214c5f920 k8s.io/utils v0.0.0-20221128185143-99ec85e7a448
sigs.k8s.io/controller-runtime v0.7.0 sigs.k8s.io/controller-runtime v0.14.5
golang.org/x/mod v0.4.2 )
require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emersion/go-sasl v0.0.0-20200509203442-7bfe0ed36a21 // indirect
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-chi/chi v4.0.0+incompatible // indirect
github.com/go-errors/errors v1.0.1 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.20.0 // indirect
github.com/go-openapi/swag v0.19.14 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/btree v1.0.1 // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/google/uuid v1.1.2 // indirect
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 // indirect
github.com/imdario/mergo v0.3.6 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
github.com/mailru/easyjson v0.7.6 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2 // indirect
github.com/moby/spdystream v0.2.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/nxadm/tail v1.4.8 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.14.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/spf13/cobra v1.6.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/xlab/treeprint v1.1.0 // indirect
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/term v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
golang.org/x/time v0.3.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.26.1 // indirect
k8s.io/component-base v0.26.1 // indirect
k8s.io/klog/v2 v2.80.1 // indirect
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
sigs.k8s.io/kustomize/api v0.12.1 // indirect
sigs.k8s.io/kustomize/kyaml v0.13.9 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
) )

761
go.sum

File diff suppressed because it is too large Load Diff

View File

@ -13,13 +13,12 @@ import (
"github.com/jenkinsci/kubernetes-operator/pkg/notifications" "github.com/jenkinsci/kubernetes-operator/pkg/notifications"
e "github.com/jenkinsci/kubernetes-operator/pkg/notifications/event" e "github.com/jenkinsci/kubernetes-operator/pkg/notifications/event"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes"
"k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/kubernetes/scheme"
ctrl "sigs.k8s.io/controller-runtime" ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/envtest" "sigs.k8s.io/controller-runtime/pkg/envtest"
"sigs.k8s.io/controller-runtime/pkg/envtest/printer"
logf "sigs.k8s.io/controller-runtime/pkg/log" logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap" "sigs.k8s.io/controller-runtime/pkg/log/zap"
// +kubebuilder:scaffold:imports // +kubebuilder:scaffold:imports
@ -34,9 +33,7 @@ func init() {
func TestAPIs(t *testing.T) { func TestAPIs(t *testing.T) {
RegisterFailHandler(Fail) RegisterFailHandler(Fail)
RunSpecsWithDefaultAndCustomReporters(t, RunSpecs(t, "Controller Suite")
"Controller Suite",
[]Reporter{printer.NewlineReporter{}})
} }
var _ = BeforeSuite(func(done Done) { var _ = BeforeSuite(func(done Done) {

View File

@ -7,12 +7,11 @@ import (
"github.com/jenkinsci/kubernetes-operator/api/v1alpha2" "github.com/jenkinsci/kubernetes-operator/api/v1alpha2"
"github.com/jenkinsci/kubernetes-operator/test/e2e" "github.com/jenkinsci/kubernetes-operator/test/e2e"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/kubernetes/scheme"
ctrl "sigs.k8s.io/controller-runtime" ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/envtest" "sigs.k8s.io/controller-runtime/pkg/envtest"
"sigs.k8s.io/controller-runtime/pkg/envtest/printer"
logf "sigs.k8s.io/controller-runtime/pkg/log" logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap" "sigs.k8s.io/controller-runtime/pkg/log/zap"
// +kubebuilder:scaffold:imports // +kubebuilder:scaffold:imports
@ -30,9 +29,7 @@ func init() {
func TestHelm(t *testing.T) { func TestHelm(t *testing.T) {
RegisterFailHandler(Fail) RegisterFailHandler(Fail)
RunSpecsWithDefaultAndCustomReporters(t, RunSpecs(t, "Controller Suite")
"Controller Suite",
[]Reporter{printer.NewlineReporter{}})
} }
var _ = BeforeSuite(func(done Done) { var _ = BeforeSuite(func(done Done) {
@ -44,7 +41,9 @@ var _ = BeforeSuite(func(done Done) {
UseExistingCluster: &useExistingCluster, UseExistingCluster: &useExistingCluster,
} }
cfg, err := testEnv.Start() var err error
// cfg is defined in this file globally.
cfg, err = testEnv.Start()
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
Expect(cfg).NotTo(BeNil()) Expect(cfg).NotTo(BeNil())

View File

@ -75,7 +75,18 @@ MEMORY_AMOUNT = 4096
##################### FROM OPERATOR SDK ######################## ##################### FROM OPERATOR SDK ########################
# Default bundle image tag # Default bundle image tag
BUNDLE_IMG ?= controller-bundle:$(VERSION) IMAGE_TAG_BASE ?= quay.io/jenkins-kubernetes-operator
# BUNDLE_GEN_FLAGS are the flags passed to the operator-sdk generate bundle command
BUNDLE_GEN_FLAGS ?= -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)
# USE_IMAGE_DIGESTS defines if images are resolved via tags or digests
# You can enable this value if you would like to use SHA Based Digests
# To enable set flag to true
USE_IMAGE_DIGESTS ?= false
ifeq ($(USE_IMAGE_DIGESTS), true)
BUNDLE_GEN_FLAGS += --use-image-digests
endif
BUNDLE_IMG ?= $(IMAGE_TAG_BASE)-bundle:v$(VERSION)
# Options for 'bundle-build' # Options for 'bundle-build'
ifneq ($(origin CHANNELS), undefined) ifneq ($(origin CHANNELS), undefined)
BUNDLE_CHANNELS := --channels=$(CHANNELS) BUNDLE_CHANNELS := --channels=$(CHANNELS)
@ -88,7 +99,6 @@ BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)
# Image URL to use all building/pushing image targets # Image URL to use all building/pushing image targets
IMG ?= controller:latest IMG ?= controller:latest
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion) # Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:trivialVersions=true,preserveUnknownFields=false"
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) # Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN)) ifeq (,$(shell go env GOBIN))
@ -96,7 +106,15 @@ GOBIN=$(shell go env GOPATH)/bin
else else
GOBIN=$(shell go env GOBIN) GOBIN=$(shell go env GOBIN)
endif endif
# Setting SHELL to bash allows bash commands to be executed by recipes.
# This is a requirement for 'setup-envtest.sh' in the test target.
# Options are set to exit when a recipe line exits non-zero or a piped command fails.
SHELL = /usr/bin/env bash -o pipefail
.SHELLFLAGS = -ec
all: build
ENVTEST_ASSETS_DIR=$(shell pwd)/testbin ENVTEST_ASSETS_DIR=$(shell pwd)/testbin
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST)))) PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
OS = $(shell go env GOOS)
ARCH = $(shell go env GOARCH)