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
37 changes: 30 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
KUBECTL ?= $(shell which kubectl)
OPERATOR_SDK ?= $(shell which operator-sdk)
OPM ?= $(shell which opm)
KUSTOMIZE ?= $(shell which kustomize)
KUSTOMIZE_VERSION=v3.8.7

ENVCRDS_DIR=$(shell pwd)/testcrds

Expand All @@ -33,7 +35,9 @@ VERSION ?= $(shell git describe --exact-match 2> /dev/null || \
RELEASE_VERSION ?= $(shell cat ./version/version.go | grep "Version =" | awk '{ print $$3}' | tr -d '"')
LATEST_VERSION ?= latest
OPERATOR_SDK_VERSION=v1.24.0
YQ_VERSION=v4.3.1
YQ_VERSION=v4.17.2
DEFAULT_CHANNEL ?= v$(shell cat ./version/version.go | grep "Version =" | awk '{ print $$3}' | tr -d '"' | cut -d '.' -f1,2)
CHANNELS ?= $(DEFAULT_CHANNEL)

LOCAL_OS := $(shell uname)
ifeq ($(LOCAL_OS),Linux)
Expand Down Expand Up @@ -134,6 +138,19 @@ else
YQ=$(shell which yq)
endif

kustomize: ## Install kustomize
ifeq (, $(shell which kustomize 2>/dev/null))
@{ \
set -e ;\
mkdir -p bin ;\
echo "Downloading kustomize ...";\
curl -sSLo - https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/$(KUSTOMIZE_VERSION)/kustomize_$(KUSTOMIZE_VERSION)_$(LOCAL_OS)_$(LOCAL_ARCH).tar.gz | tar xzf - -C bin/ ;\
}
KUSTOMIZE=$(realpath ./bin/kustomize)
else
KUSTOMIZE=$(shell which kustomize)
endif

operator-sdk:
ifneq ($(shell operator-sdk version | cut -d ',' -f1 | cut -d ':' -f2 | tr -d '"' | xargs | cut -d '.' -f1), v1)
@{ \
Expand Down Expand Up @@ -191,6 +208,10 @@ bundle-manifests:
$(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle \
-q --overwrite --version $(OPERATOR_VERSION) $(BUNDLE_METADATA_OPTS)
$(OPERATOR_SDK) bundle validate ./bundle
$(YQ) eval-all -i '.spec.relatedImages = load("config/manifests/bases/operand-deployment-lifecycle-manager.clusterserviceversion.yaml").spec.relatedImages' bundle/manifests/operand-deployment-lifecycle-manager.clusterserviceversion.yaml
# Need to replace fields this way to avoid changing PROJECT name and CSV file name, which may or may not impact CICD automation
$(YQ) e -i '.annotations["operators.operatorframework.io.bundle.package.v1"] = "ibm-odlm"' bundle/metadata/annotations.yaml
sed -i'' s/operand-deployment-lifecycle-manager/ibm-odlm/ bundle.Dockerfile

generate-all: manifests kustomize operator-sdk ## Generate bundle manifests, metadata and package manifests
$(OPERATOR_SDK) generate kustomize manifests -q
Expand Down Expand Up @@ -245,8 +266,8 @@ build-operator-image: $(CONFIG_DOCKER_TARGET) ## Build the operator image.
--build-arg GOARCH=$(LOCAL_ARCH) -f Dockerfile .

build-operator-dev-image: ## Build the operator dev image.
@echo "Building the $(OPERATOR_IMAGE_NAME) docker image..."
@docker build -t $(OPERATOR_IMAGE_NAME):$(VERSION) \
@echo "Building the $(DEV_REGISTRY)/$(OPERATOR_IMAGE_NAME) docker image..."
@docker build -t $(DEV_REGISTRY)/$(OPERATOR_IMAGE_NAME):$(VERSION) \
--build-arg VCS_REF=$(VCS_REF) --build-arg VCS_URL=$(VCS_URL) \
--build-arg GOARCH=$(LOCAL_ARCH) -f Dockerfile .

Expand All @@ -260,7 +281,6 @@ build-test-operator-image: $(CONFIG_DOCKER_TARGET) ## Build the operator test im

build-push-dev-image: build-operator-dev-image ## Build and push the operator dev images.
@echo "Pushing the $(DEV_REGISTRY)/$(OPERATOR_IMAGE_NAME):$(VERSION) docker image to $(DEV_REGISTRY)..."
@docker tag $(OPERATOR_IMAGE_NAME):$(VERSION) $(DEV_REGISTRY)/$(OPERATOR_IMAGE_NAME):$(VERSION)
@docker push $(DEV_REGISTRY)/$(OPERATOR_IMAGE_NAME):$(VERSION)

build-push-image: $(CONFIG_DOCKER_TARGET) build-operator-image ## Build and push the operator images.
Expand All @@ -269,12 +289,9 @@ build-push-image: $(CONFIG_DOCKER_TARGET) build-operator-image ## Build and pus
@docker push $(ARTIFACTORYA_REGISTRY)/$(OPERATOR_IMAGE_NAME)-$(LOCAL_ARCH):$(VERSION)

build-push-bundle-image: yq
@cp -f bundle/manifests/operand-deployment-lifecycle-manager.clusterserviceversion.yaml /tmp/operand-deployment-lifecycle-manager.clusterserviceversion.yaml
$(YQ) eval -i 'del(.spec.replaces)' bundle/manifests/operand-deployment-lifecycle-manager.clusterserviceversion.yaml
@docker build -f bundle.Dockerfile -t $(QUAY_REGISTRY)/$(BUNDLE_IMAGE_NAME)-$(LOCAL_ARCH):$(VERSION) .
@echo "Pushing the $(BUNDLE_IMAGE_NAME) docker image for $(LOCAL_ARCH)..."
@docker push $(QUAY_REGISTRY)/$(BUNDLE_IMAGE_NAME)-$(LOCAL_ARCH):$(VERSION)
@mv /tmp/operand-deployment-lifecycle-manager.clusterserviceversion.yaml bundle/manifests/operand-deployment-lifecycle-manager.clusterserviceversion.yaml

build-catalog-source:
@opm -u docker index add --bundles $(QUAY_REGISTRY)/$(BUNDLE_IMAGE_NAME)-$(LOCAL_ARCH):$(VERSION) --tag $(QUAY_REGISTRY)/$(OPERATOR_IMAGE_NAME)-catalog:$(VERSION)
Expand All @@ -285,6 +302,12 @@ build-catalog: build-push-bundle-image build-catalog-source
multiarch-image: $(CONFIG_DOCKER_TARGET) ## Generate multiarch images for operator image.
@MAX_PULLING_RETRY=20 RETRY_INTERVAL=30 common/scripts/multiarch_image.sh $(ARTIFACTORYA_REGISTRY) $(OPERATOR_IMAGE_NAME) $(VERSION) $(RELEASE_VERSION)

run-bundle:
$(OPERATOR_SDK) run bundle $(QUAY_REGISTRY)/$(BUNDLE_IMAGE_NAME)-$(LOCAL_ARCH):$(VERSION) --install-mode OwnNamespace

cleanup-bundle:
$(OPERATOR_SDK) cleanup ibm-odlm

##@ Help
help: ## Display this help
@echo "Usage:\n make \033[36m<target>\033[0m"
Expand Down
7 changes: 6 additions & 1 deletion api/v1alpha1/operandconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,17 @@ type OperandConfigSpec struct {
Services []ConfigService `json:"services,omitempty"`
}

// +kubebuilder:pruning:PreserveUnknownFields
type ExtensionWithMarker struct {
runtime.RawExtension `json:",inline"`
}

// ConfigService defines the configuration of the service.
type ConfigService struct {
// Name is the subscription name.
Name string `json:"name"`
// Spec is the configuration map of custom resource.
Spec map[string]runtime.RawExtension `json:"spec,omitempty"`
Spec map[string]ExtensionWithMarker `json:"spec,omitempty"`
// State is a flag to enable or disable service.
State string `json:"state,omitempty"`
// Resources is used to specify the kubernetes resources that are needed for the service.
Expand Down
82 changes: 81 additions & 1 deletion api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bundle.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ LABEL operators.operatorframework.io.bundle.metadata.v1=metadata/
LABEL operators.operatorframework.io.bundle.package.v1=ibm-odlm
LABEL operators.operatorframework.io.bundle.channels.v1=v4.2
LABEL operators.operatorframework.io.bundle.channel.default.v1=v4.2
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.24.0
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.29.0
LABEL operators.operatorframework.io.metrics.mediatype.v1=metrics+v1
LABEL operators.operatorframework.io.metrics.project_layout=go.kubebuilder.io/v3

Expand Down
Loading