Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: bump operator-go 0.9.0 and remove database #55

Merged
merged 2 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .chainsaw copy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: Configuration
metadata:
name: custom-config
spec:
timeouts:
apply: 300s
assert: 600s
cleanup: 240s
delete: 240s
error: 180s
exec: 300s
skipDelete: false
failFast: true
forceTerminationGracePeriod: 10s
54 changes: 14 additions & 40 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,47 +23,17 @@ jobs:


golang-lint:
name: Golang Lint
runs-on: ubuntu-22.04
name: golang-lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.22'
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Require: The version of golangci-lint to use.
# When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
# When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
version: v1.54

# Optional: working directory, useful for monorepos
# working-directory: somedir

# Optional: golangci-lint command line arguments.
#
# Note: By default, the `.golangci.yml` file should be at the root of the repository.
# The location of the configuration file can be changed by using `--config=`
# args: --timeout=30m --config=/my/path/.golangci.yml --issues-exit-code=0
args: --timeout=30m

# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true

# Optional: if set to true, then all caching functionality will be completely disabled,
# takes precedence over all other caching options.
# skip-cache: true

# Optional: if set to true, then the action won't cache or restore ~/go/pkg.
# skip-pkg-cache: true

# Optional: if set to true, then the action won't cache or restore ~/.cache/go-build.
# skip-build-cache: true

# Optional: The mode to install golangci-lint. It can be 'binary' or 'goinstall'.
# install-mode: "goinstall"
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.22'
cache: false
- name: golangci-lint
run: |
make lint


golang-test:
Expand Down Expand Up @@ -129,3 +99,7 @@ jobs:
run: |
make catalog
make catalog-buildx
- name: Build and push catalog
run: |
make catalog
make catalog-buildx
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM golang:1.22 as builder
FROM golang:1.23 as builder
ARG TARGETOS
ARG TARGETARCH

Expand Down
96 changes: 93 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ help: ## Display this help.

.PHONY: manifests
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
go get github.com/zncdatadev/operator-go@v0.8.3
$(CONTROLLER_GEN) rbac:roleName=manager-role crd:allowDangerousTypes=true,generateEmbeddedObjectMeta=true webhook paths="github.com/zncdatadev/operator-go/pkg/apis/database/..." output:crd:artifacts:config=config/crd/bases
go get github.com/zncdatadev/operator-go@v0.9.0
$(CONTROLLER_GEN) rbac:roleName=manager-role crd:allowDangerousTypes=true,generateEmbeddedObjectMeta=true webhook paths="github.com/zncdatadev/operator-go/pkg/apis/s3/..." output:crd:artifacts:config=config/crd/bases
$(CONTROLLER_GEN) rbac:roleName=manager-role crd:allowDangerousTypes=true,generateEmbeddedObjectMeta=true webhook paths="github.com/zncdatadev/operator-go/pkg/apis/authentication/..." output:crd:artifacts:config=config/crd/bases

Expand All @@ -120,14 +119,31 @@ fmt: ## Run go fmt against code.
vet: ## Run go vet against code.
go vet ./...


GOLANGCI_LINT = $(shell pwd)/bin/golangci-lint
GOLANGCI_LINT_VERSION ?= v1.60.3
golangci-lint:
@[ -f $(GOLANGCI_LINT) ] || { \
set -e ;\
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell dirname $(GOLANGCI_LINT)) $(GOLANGCI_LINT_VERSION) ;\
}

.PHONY: lint
lint: golangci-lint ## Run golangci-lint linter & yamllint
$(GOLANGCI_LINT) run --timeout 5m

.PHONY: lint-fix
lint-fix: golangci-lint ## Run golangci-lint linter and perform fixes
$(GOLANGCI_LINT) run --fix

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

##@ Build

.PHONY: build
build: manifests generate fmt vet ## Build manager binary.
build: manifests generate fmt vet lint ## Build manager binary.
go build -o bin/manager cmd/main.go

.PHONY: run
Expand Down Expand Up @@ -325,3 +341,77 @@ catalog-buildx: catalog-validate ## Build and push a catalog image for cross-pla
$(CONTAINER_TOOL) buildx use project-v3-builder
- $(CONTAINER_TOOL) buildx build --push --platform=$(PLATFORMS) -f catalog.Dockerfile --tag ${CATALOG_IMG} .
- $(CONTAINER_TOOL) buildx rm project-v3-builder


##@ E2E

# kind
KIND_VERSION ?= v0.23.0

KINDTEST_K8S_VERSION ?= 1.26.14

KIND_IMAGE ?= kindest/node:v${KINDTEST_K8S_VERSION}

KIND_KUBECONFIG ?= ./kind-kubeconfig-$(KINDTEST_K8S_VERSION)
KIND_CLUSTER_NAME ?= ${PROJECT_NAME}-$(KINDTEST_K8S_VERSION)

.PHONY: kind
KIND = $(LOCALBIN)/kind
kind: ## Download kind locally if necessary.
ifeq (,$(shell which $(KIND)))
ifeq (,$(shell which kind 2>/dev/null))
@{ \
set -e ;\
go install sigs.k8s.io/kind@$(KIND_VERSION) ;\
}
KIND = $(GOBIN)/bin/kind
else
KIND = $(shell which kind)
endif
endif

OLM_VERSION ?= v0.28.0
KIND_CONFIG ?= test/e2e/kind-config.yaml

# Create a kind cluster, install ingress-nginx, and wait for it to be available.
.PHONY: kind-create
kind-create: kind ## Create a kind cluster.
$(KIND) create cluster --config $(KIND_CONFIG) --image $(KIND_IMAGE) --name $(KIND_CLUSTER_NAME) --kubeconfig $(KIND_KUBECONFIG) --wait 120s
KUBECONFIG=$(KIND_KUBECONFIG) make kind-setup

.PHONY: kind-setup
kind-setup: kind ## setup kind cluster base environment
@echo "Setup kind cluster base environment, install ingress-nginx and OLM"
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml
kubectl -n ingress-nginx wait deployment ingress-nginx-controller --for=condition=available --timeout=300s
curl -sSL https://github.com/operator-framework/operator-lifecycle-manager/releases/download/$(OLM_VERSION)/install.sh | bash -s $(OLM_VERSION)

.PHONY: kind-delete
kind-delete: kind ## Delete a kind cluster.
$(KIND) delete cluster --name $(KIND_CLUSTER_NAME)

# chainsaw

CHAINSAW_VERSION ?= v0.2.6
CHAINSAW = $(LOCALBIN)/chainsaw

.PHONY: chainsaw
chainsaw: $(CHAINSAW) ## Download chainsaw locally if necessary.
$(CHAINSAW): $(LOCALBIN)
test -s $(LOCALBIN)/chainsaw && $(LOCALBIN)/chainsaw version | grep -q $(CHAINSAW_VERSION) || \
GOBIN=$(LOCALBIN) go install github.com/kyverno/chainsaw@$(CHAINSAW_VERSION)

.PHONY: chainsaw-setup
chainsaw-setup: manifests kustomize ## Run the chainsaw setup
@echo "\nSetup chainsaw test environment"
make docker-build
$(KIND) --name $(KIND_CLUSTER_NAME) load docker-image $(IMG)
KUBECONFIG=$(KIND_KUBECONFIG) make deploy

.PHONY: chainsaw-test
chainsaw-test: chainsaw ## Run the chainsaw test
KUBECONFIG=$(KIND_KUBECONFIG) $(CHAINSAW) test --cluster cluster-1=$(KIND_KUBECONFIG) --test-dir ./test/e2e/

.PHONY: chainsaw-cleanup
chainsaw-cleanup: manifests kustomize ## Run the chainsaw cleanup
KUBECONFIG=$(KIND_KUBECONFIG) make undeploy
18 changes: 0 additions & 18 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,6 @@ resources:
kind: AuthenticationClass
path: github.com/zncdatadev/commons-operator/api/authentication/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: zncdata.dev
group: database
kind: Database
path: github.com/zncdatadev/commons-operator/api/database/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
Expand All @@ -48,13 +39,4 @@ resources:
kind: S3Bucket
path: github.com/zncdatadev/commons-operator/api/s3/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: zncdata.dev
group: database
kind: DatabaseConnection
path: github.com/zncdatadev/commons-operator/api/database/v1alpha1
version: v1alpha1
version: "3"
Loading
Loading