Skip to content
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
14 changes: 8 additions & 6 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
name: Lint

on:
push:
workflow_dispatch:
pull_request:
merge_group:
push:
branches:
- main

jobs:
lint:
name: Run on Ubuntu
runs-on: ubuntu-latest
steps:
- name: Clone the code
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: Setup Go
uses: actions/setup-go@v5
uses: actions/setup-go@v6
with:
go-version-file: go.mod

- name: Run linter
uses: golangci/golangci-lint-action@v8
with:
version: v2.3.0
run: make lint
63 changes: 63 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Release

on:
workflow_dispatch:
push:
branches:
- 'main'
tags:
- 'v*'
pull_request:
branches:
- main
merge_group:

jobs:
goreleaser:
name: Release
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v5
with:
fetch-depth: 0

- name: Install Go
uses: actions/setup-go@v6
with:
go-version-file: "go.mod"

- name: Docker Login
uses: docker/login-action@v3
if: ${{ github.event_name != 'pull_request' }}
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}

- name: Set the release related variables
run: |
if [[ $GITHUB_REF == refs/tags/* ]]; then
# Release tags.
echo VERSION="$(echo "${GITHUB_REF#refs/tags/}" | sed 's/^v//')" >> $GITHUB_ENV
echo RELEASE=true >> $GITHUB_ENV
elif [[ $GITHUB_REF == refs/heads/main ]]; then
# 'main' branch build.
echo TAG=snapshot >> $GITHUB_ENV
echo RELEASE=true >> $GITHUB_ENV
fi

- name: Release
run: make release

- name: Create Release
id: create_release
uses: actions/create-release@v1
if: ${{ github.event_name != 'pull_request' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
4 changes: 2 additions & 2 deletions .github/workflows/test-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Clone the code
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: Setup Go
uses: actions/setup-go@v5
uses: actions/setup-go@v6
with:
go-version-file: go.mod

Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
name: Tests

on:
push:
workflow_dispatch:
pull_request:
merge_group:
push:
branches:
- main

jobs:
test:
name: Run on Ubuntu
runs-on: ubuntu-latest
steps:
- name: Clone the code
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: Setup Go
uses: actions/setup-go@v5
uses: actions/setup-go@v6
with:
go-version-file: go.mod

Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Generated catalog
catalog/catalog.json

# Binaries for programs and plugins
*.exe
*.exe~
Expand Down
80 changes: 61 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# To re-generate a bundle for another specific version without changing the standard setup, you can:
# - use the VERSION as arg of the bundle target (e.g make bundle VERSION=0.0.2)
# - use environment variables to overwrite this value (e.g export VERSION=0.0.2)
VERSION ?= 0.0.5
VERSION ?= 0.0.0

# CHANNELS define the bundle channels used in the bundle.
# Add a new line here if you would like to change its default config. (E.g CHANNELS = "candidate,fast,stable")
Expand All @@ -24,19 +24,26 @@ BUNDLE_DEFAULT_CHANNEL := --default-channel=$(DEFAULT_CHANNEL)
endif
BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)

RELEASE ?= false
ifeq ($(RELEASE), true)
DOCKER_BUILDX_FLAGS += --push
endif

# IMAGE_TAG_BASE defines the docker.io namespace and part of the image name for remote images.
# This variable is used to construct full image tags for bundle and catalog images.
#
# For example, running 'make bundle-build bundle-push catalog-build catalog-push' will build and push both
# quay.io/olmtest/webhook-operator:$VERSION and quay.io/olmtest/webhook-operator-bundle:$VERSION.
IMAGE_TAG_BASE ?= quay.io/olmtest/webhook-operator

TAG ?= v$(VERSION)

# BUNDLE_IMG defines the image:tag used for the bundle.
# You can use it as an arg. (E.g make bundle-build BUNDLE_IMG=<some-registry>/<project-name-bundle>:<tag>)
BUNDLE_IMG ?= $(IMAGE_TAG_BASE)-bundle:v$(VERSION)
BUNDLE_IMG ?= $(IMAGE_TAG_BASE)-bundle:$(TAG)

# The image tag given to the resulting catalog image (e.g. make catalog-build CATALOG_IMG=example.com/operator-catalog:v0.2.0).
CATALOG_IMG ?= $(IMAGE_TAG_BASE)-index:v$(VERSION)
CATALOG_IMG ?= $(IMAGE_TAG_BASE)-index:$(TAG)

# BUNDLE_GEN_FLAGS are the flags passed to the operator-sdk generate bundle command
BUNDLE_GEN_FLAGS ?= -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)
Expand All @@ -54,7 +61,7 @@ endif
OPERATOR_SDK_VERSION ?= v1.41.1

# Image URL to use all building/pushing image targets
IMG ?= quay.io/olmtest/webhook-operator:v$(VERSION)
IMG ?= quay.io/olmtest/webhook-operator:$(TAG)

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
Expand Down Expand Up @@ -116,6 +123,14 @@ vet: ## Run go vet against code.
test: manifests generate fmt vet setup-envtest ## Run tests.
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test $$(go list ./... | grep -v /e2e) -coverprofile cover.out

.PHONY: tidy
tidy:
go mod tidy

.PHONY: verify
verify: tidy fmt manifests generate
git diff --exit-code

# TODO(user): To use a different vendor for e2e tests, modify the setup under 'tests/e2e'.
# The default setup assumes Kind is pre-installed and builds/loads the Manager Docker image locally.
# CertManager is installed by default; skip with:
Expand Down Expand Up @@ -191,24 +206,10 @@ docker-buildx: ## Build and push docker image for the manager for cross-platform
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
- $(CONTAINER_TOOL) buildx create --name webhook-operator-builder
$(CONTAINER_TOOL) buildx use webhook-operator-builder
- $(CONTAINER_TOOL) buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross .
- $(CONTAINER_TOOL) buildx build $(DOCKER_BUILDX_FLAGS) --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross .
- $(CONTAINER_TOOL) buildx rm webhook-operator-builder
rm Dockerfile.cross

.PHONY: bundle-docker-buildx
bundle-docker-buildx: ## Build and push bundle image with cross-platform support
- $(CONTAINER_TOOL) buildx create --name webhook-operator-bundle-builder
$(CONTAINER_TOOL) buildx use webhook-operator-bundle-builder
- $(CONTAINER_TOOL) buildx build --push --platform=$(PLATFORMS) --tag ${BUNDLE_IMG} -f bundle.Dockerfile .
- $(CONTAINER_TOOL) buildx rm webhook-operator-bundle-builder

.PHONY: index-docker-buildx
index-docker-buildx: ## Build and push docker image for the manager for cross-platform support
- $(CONTAINER_TOOL) buildx create --name webhook-operator-index-builder
$(CONTAINER_TOOL) buildx use webhook-operator-index-builder
- $(CONTAINER_TOOL) buildx build --push --platform=$(PLATFORMS) --tag ${CATALOG_IMG} -f catalog.Dockerfile .
- $(CONTAINER_TOOL) buildx rm webhook-operator-index-builder

.PHONY: build-installer
build-installer: manifests generate kustomize ## Generate a consolidated YAML with CRDs and deployment.
mkdir -p dist
Expand Down Expand Up @@ -337,3 +338,44 @@ bundle-build: ## Build the bundle image.
.PHONY: bundle-push
bundle-push: ## Push the bundle image.
$(MAKE) docker-push IMG=$(BUNDLE_IMG)

.PHONY: bundle-docker-buildx
bundle-docker-buildx: bundle ## Build and push bundle image with cross-platform support
- $(CONTAINER_TOOL) buildx create --name webhook-operator-bundle-builder
$(CONTAINER_TOOL) buildx use webhook-operator-bundle-builder
- $(CONTAINER_TOOL) buildx build $(DOCKER_BUILDX_FLAGS) --platform=$(PLATFORMS) --tag ${BUNDLE_IMG} -f bundle.Dockerfile .
- $(CONTAINER_TOOL) buildx rm webhook-operator-bundle-builder

.PHONY: opm
OPM = $(LOCALBIN)/opm
opm: ## Download opm locally if necessary.
ifeq (,$(wildcard $(OPM)))
ifeq (,$(shell which opm 2>/dev/null))
@{ \
set -e ;\
mkdir -p $(dir $(OPM)) ;\
OS=$(shell go env GOOS) && ARCH=$(shell go env GOARCH) && \
curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/latest/download/$${OS}-$${ARCH}-opm ;\
chmod +x $(OPM) ;\
}
else
OPM = $(shell which opm)
endif
endif

.PHONY: build-catalog
build-catalog: opm
@# Create base catalog from template
sed "s/{{ VERSION }}/$(VERSION)/g" catalog/catalog.tpl > catalog/catalog.json
@# Add bundle FBC
$(OPM) render ./bundle

.PHONY: catalog-docker-buildx
catalog-docker-buildx: build-catalog ## Build and push docker image for the manager for cross-platform support
- $(CONTAINER_TOOL) buildx create --name webhook-operator-index-builder
$(CONTAINER_TOOL) buildx use webhook-operator-index-builder
- $(CONTAINER_TOOL) buildx build $(DOCKER_BUILDX_FLAGS) --platform=$(PLATFORMS) --tag ${CATALOG_IMG} -f catalog.Dockerfile .
- $(CONTAINER_TOOL) buildx rm webhook-operator-index-builder

.PHONY: release
release: docker-buildx bundle-docker-buildx catalog-docker-buildx
8 changes: 4 additions & 4 deletions bundle/manifests/webhook-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ metadata:
}
]
capabilities: Basic Install
createdAt: "2025-09-29T13:06:16Z"
createdAt: "2025-09-30T13:14:21Z"
operators.operatorframework.io/builder: operator-sdk-v1.41.1
operators.operatorframework.io/project_layout: go.kubebuilder.io/v4
name: webhook-operator.v0.0.5
name: webhook-operator.v0.0.0
namespace: placeholder
spec:
apiservicedefinitions: {}
Expand Down Expand Up @@ -126,7 +126,7 @@ spec:
- --webhook-cert-path=/tmp/k8s-webhook-server/serving-certs
command:
- /manager
image: quay.io/olmtest/webhook-operator:v0.0.5
image: quay.io/olmtest/webhook-operator:v0.0.0
livenessProbe:
httpGet:
path: /healthz
Expand Down Expand Up @@ -228,7 +228,7 @@ spec:
maturity: alpha
provider:
name: operator-framework
version: 0.0.5
version: 0.0.0
webhookdefinitions:
- admissionReviewVersions:
- v1
Expand Down
5 changes: 3 additions & 2 deletions catalog.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# The builder image is expected to contain
# /bin/opm (with serve subcommand)
FROM quay.io/operator-framework/opm:latest as builder
FROM quay.io/operator-framework/opm:latest AS builder

# Copy FBC root into image at /configs and pre-populate serve cache
ADD catalog /configs
ADD catalog/.indexignore /configs/.indexignore
ADD catalog/catalog.json /configs/catalog.json
RUN ["/bin/opm", "serve", "/configs", "--cache-dir=/tmp/cache", "--cache-only"]

FROM quay.io/operator-framework/opm:latest
Expand Down
3 changes: 3 additions & 0 deletions catalog/.indexignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/expected_all.json
/catalog.tpl
..*
Loading