Skip to content

Commit

Permalink
Adds improvements to bundle generation
Browse files Browse the repository at this point in the history
  • Loading branch information
phantomjinx committed Nov 28, 2023
1 parent 91d918a commit 77fe92c
Show file tree
Hide file tree
Showing 13 changed files with 590 additions and 26 deletions.
60 changes: 55 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ DEFAULT_IMAGE := docker.io/${ORG}/${PROJECT}
IMAGE ?= $(DEFAULT_IMAGE)
DEFAULT_TAG := latest
TAG ?= $(DEFAULT_TAG)
VERSION ?= 0.5.0
VERSION ?= 1.0.0
HAWTIO_ONLINE_VERSION ?= latest
HAWTIO_ONLINE_IMAGE_NAME ?= docker.io/${ORG}/hawtio
DEBUG ?= false
LAST_RELEASED_IMAGE_NAME := hawtio-operator
LAST_RELEASED_VERSION ?= 0.5.0

#
# Versions of tools and binaries
Expand Down Expand Up @@ -108,8 +110,56 @@ endif

# Generate bundle manifests and metadata

bundle: kustomize operator-sdk
$(KUSTOMIZE) build bundle | $(OPERATOR_SDK) generate bundle --kustomize-dir bundle --version $(VERSION)
DEFAULT_CHANNEL ?= $(shell echo "stable-v$(word 1,$(subst ., ,$(lastword $(VERSION))))")
CHANNELS ?= $(DEFAULT_CHANNEL),latest
PACKAGE := hawtio-operator
MANIFESTS := bundle
CSV_VERSION := $(VERSION)
CSV_NAME := $(PACKAGE).v$(CSV_VERSION)
CSV_DISPLAY_NAME := Hawtio Operator
CSV_FILENAME := $(PACKAGE).clusterserviceversion.yaml
CSV_PATH := $(MANIFESTS)/bases/$(CSV_FILENAME)
CSV_REPLACES := $(LAST_RELEASED_IMAGE_NAME).v$(LAST_RELEASED_VERSION)
IMAGE_NAME ?= docker.io/hawtio/operator

# Options for 'bundle-build'
ifneq ($(origin CHANNELS), undefined)
BUNDLE_CHANNELS := --channels=$(CHANNELS)
endif
ifneq ($(origin DEFAULT_CHANNEL), undefined)
BUNDLE_DEFAULT_CHANNEL := --default-channel=$(DEFAULT_CHANNEL)
endif
ifneq ($(origin PACKAGE), undefined)
BUNDLE_PACKAGE := --package=$(PACKAGE)
endif
BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL) $(BUNDLE_PACKAGE)

#
# Tailor the manifest according to default values for this project
# Note. to successfully make the bundle the name must match that specified in the PROJECT file
#
pre-bundle:
# bundle name must match that which appears in PROJECT file
@sed -i 's/projectName: .*/projectName: $(PACKAGE)/' PROJECT
@sed -i 's~^ containerImage: .*~ containerImage: $(IMAGE):$(VERSION)~' $(CSV_PATH)
@sed -i 's/^ name: .*.\(v.*\)/ name: $(CSV_NAME)/' $(CSV_PATH)
@sed -i 's/^ displayName: .*/ displayName: $(CSV_DISPLAY_NAME)/' $(CSV_PATH)
@sed -i 's/^ version: .*/ version: $(CSV_VERSION)/' $(CSV_PATH)
@if grep -q replaces $(CSV_PATH); \
then sed -i 's/^ replaces: .*/ replaces: $(CSV_REPLACES)/' $(CSV_PATH); \
else sed -i '/ version: ${CSV_VERSION}/a \ \ replaces: $(CSV_REPLACES)' $(CSV_PATH); \
fi

bundle: kustomize operator-sdk pre-bundle
@# Display BUNDLE_METADATA_OPTS for debugging
$(info BUNDLE_METADATA_OPTS=$(BUNDLE_METADATA_OPTS))
@# Sets the operator image to the preferred image:tag
@cd bundle && $(KUSTOMIZE) edit set image $(IMAGE_NAME)=$(IMAGE):$(VERSION)
@# Build kustomize manifests
$(KUSTOMIZE) build bundle | $(OPERATOR_SDK) generate bundle \
--kustomize-dir bundle \
--version $(VERSION) -q --overwrite \
$(BUNDLE_METADATA_OPTS)

validate-bundle: operator-sdk
$(OPERATOR_SDK) bundle validate ./bundle --select-optional suite=operatorframework
Expand Down Expand Up @@ -146,12 +196,12 @@ endif

operator-sdk: detect-os
@echo "####### Installing operator-sdk version $(OPERATOR_SDK_VERSION)..."
curl \
@curl \
-s -L https://github.com/operator-framework/operator-sdk/releases/download/$(OPERATOR_SDK_VERSION)/operator-sdk_$(OS_LOWER)_amd64 \
-o operator-sdk ; \
chmod +x operator-sdk ;\
mkdir -p $(GOBIN) ;\
mv operator-sdk $(GOBIN)/ ;
mv operator-sdk $(GOBIN)/ ;
OPERATOR_SDK=$(GOBIN)/operator-sdk

#
Expand Down
5 changes: 3 additions & 2 deletions bundle.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ LABEL operators.operatorframework.io.bundle.mediatype.v1=registry+v1
LABEL operators.operatorframework.io.bundle.manifests.v1=manifests/
LABEL operators.operatorframework.io.bundle.metadata.v1=metadata/
LABEL operators.operatorframework.io.bundle.package.v1=hawtio-operator
LABEL operators.operatorframework.io.bundle.channels.v1=alpha
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.11.0+git
LABEL operators.operatorframework.io.bundle.channels.v1=stable-v1,latest
LABEL operators.operatorframework.io.bundle.channel.default.v1=stable-v1
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.28.0
LABEL operators.operatorframework.io.metrics.mediatype.v1=metrics+v1
LABEL operators.operatorframework.io.metrics.project_layout=go.kubebuilder.io/v2

Expand Down
4 changes: 3 additions & 1 deletion bundle/bases/hawtio-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ metadata:
categories: Integration & Delivery
certified: "false"
description: Hawtio eases the discovery and management of Java applications deployed on OpenShift.
containerImage: docker.io/hawtio/operator
containerImage: docker.io/hawtio/operator:1.0.0
repository: https://github.com/hawtio/hawtio-operator
support: Red Hat
name: hawtio-operator.v1.0.0
spec:
displayName: Hawtio Operator
maintainers:
Expand Down Expand Up @@ -66,3 +67,4 @@ spec:
type: MultiNamespace
- supported: false
type: AllNamespaces
replaces: hawtio-operator.v0.5.0
7 changes: 4 additions & 3 deletions bundle/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- ../deploy/crd
- ../deploy/crs
- ../deploy
- ../deploy/crd
- ../deploy/crs
- ../deploy
- scorecard
Loading

0 comments on commit 77fe92c

Please sign in to comment.