Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ kuttl-test.json
*.swo
*~

# Generated file-based catalog artifacts
catalog/
catalog.Dockerfile

# ignore vendor
vendor/
.vscode/
Expand Down
2 changes: 1 addition & 1 deletion Containerfile.plugin
Comment thread
olivergondza marked this conversation as resolved.
Outdated
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ FROM registry.redhat.io/rhel8/go-toolset:1.22.7-5.1731464728 AS builder
ENV LANG=en_US.utf8
ENV GIT_COMMITTER_NAME devtools
ENV GIT_COMMITTER_EMAIL devtools@redhat.com
LABEL com.redhat.delivery.appregistry=true
LABEL com.redhat.delivery.appregistry=false

WORKDIR /gitops-operator

Expand Down
46 changes: 30 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -267,15 +267,17 @@ rm -rf $$TMP_DIR ;\
endef

.PHONY: bundle
bundle: operator-sdk manifests kustomize ## Generate bundle manifests and metadata, then validate generated files.
bundle: operator-sdk opm manifests kustomize ## Generate bundle manifests and metadata, then validate generated files.
$(OPERATOR_SDK) generate kustomize manifests -q
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
$(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle $(BUNDLE_GEN_FLAGS)
$(OPERATOR_SDK) bundle validate ./bundle
$(OPM) render ./bundle -o yaml | grep -E 'schema: olm.bundle' # Fail if using v0 format

.PHONY: bundle-build
bundle-build: ## Build the bundle image.
$(CONTAINER_RUNTIME) build -f bundle.Dockerfile -t $(BUNDLE_IMG) .
$(CONTAINER_RUNTIME) image inspect $(BUNDLE_IMG) --format '{{json .Config.Labels}}' | grep 'operators.operatorframework.io.test.mediatype.v1' # Fail if using v0 format
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated

.PHONY: bundle-push
bundle-push: ## Push the bundle image.
Expand All @@ -300,7 +302,7 @@ 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/download/v1.23.0/$${OS}-$${ARCH}-opm ;\
curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.72.0/$${OS}-$${ARCH}-opm ;\
chmod +x $(OPM) ;\
}
else
Expand All @@ -309,31 +311,43 @@ endif
endif


# A comma-separated list of bundle images (e.g. make catalog-build BUNDLE_IMGS=example.com/operator-bundle:v0.1.0,example.com/operator-bundle:v0.2.0).
# These images MUST exist in a registry and be pull-able.
BUNDLE_IMGS ?= $(BUNDLE_IMG)

# 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)-catalog:v$(VERSION)

# Set CATALOG_BASE_IMG to an existing catalog image tag to add $BUNDLE_IMGS to that image.
ifneq ($(origin CATALOG_BASE_IMG), undefined)
FROM_INDEX_OPT := --from-index $(CATALOG_BASE_IMG)
endif
# File-based catalog (FBC) output directory. Dockerfile is generated beside it as $(CATALOG_DIR).Dockerfile.
CATALOG_DIR = catalog

# Build a catalog image by adding bundle images to an empty catalog using the operator package manager tool, 'opm'.
# This recipe invokes 'opm' in 'semver' bundle add mode. For more information on add modes, see:
# https://github.com/operator-framework/community-operators/blob/7f1438c/docs/packaging-operator.md#updating-your-existing-operator
# Build a file-based catalog image from the local registry+v1 bundle (./bundle).
# BUNDLE_IMG is stamped into the olm.bundle entry so OLM can pull the published bundle.
.PHONY: catalog-build
catalog-build: opm ## Build a catalog image.
$(OPM) index add --container-tool $(shell basename $(CONTAINER_RUNTIME)) --mode semver --tag $(CATALOG_IMG) --bundles $(BUNDLE_IMGS) $(FROM_INDEX_OPT)
catalog-build: opm bundle ## Build a file-based catalog image.
rm -rf $(CATALOG_DIR) $(CATALOG_DIR).Dockerfile
mkdir -p $(CATALOG_DIR)
$(OPM) init gitops-operator --default-channel=$(shell echo $(DEFAULT_CHANNEL) | tr -d '"') -o yaml > $(CATALOG_DIR)/index.yaml
$(OPM) render ./bundle -o yaml | sed 's|^image: ""$$|image: $(BUNDLE_IMG)|' >> $(CATALOG_DIR)/index.yaml
@bundle_name="gitops-operator.v$(VERSION)"; \
for ch in $$(echo $(CHANNELS) | tr -d '"' | tr ',' ' '); do \
printf '%s\n' '---' 'schema: olm.channel' "package: gitops-operator" "name: $${ch}" 'entries:' " - name: $${bundle_name}" >> $(CATALOG_DIR)/index.yaml; \
done
$(OPM) validate $(CATALOG_DIR)
$(OPM) generate dockerfile $(CATALOG_DIR)
$(CONTAINER_RUNTIME) build -f $(CATALOG_DIR).Dockerfile -t $(CATALOG_IMG) .

# Validate that the catalog image is using the v1 format
@cid=$$($(CONTAINER_RUNTIME) create $(CATALOG_IMG)); \
if $(CONTAINER_RUNTIME) cp $$cid:/database/index.db /tmp/gitops-catalog-index.db 2>/dev/null; then \
$(CONTAINER_RUNTIME) rm $$cid >/dev/null; rm -f /tmp/gitops-catalog-index.db; \
echo "ERROR: $(CATALOG_IMG) uses SQLite index.db (deprecated/v0 catalog format)"; \
exit 1; \
fi; \
$(CONTAINER_RUNTIME) rm $$cid >/dev/null
$(OPM) render $(CATALOG_DIR) -o yaml | grep -E 'schema: olm\.(package|channel|bundle)' # Fail if using v0 format

# Push the catalog image.
.PHONY: catalog-push
catalog-push: ## Push a catalog image.
$(MAKE) docker-push IMG=$(CATALOG_IMG)


.PHONY: gosec
gosec: go_sec
$(GO_SEC) --exclude-dir "hack/upgrade-rollouts-manager" ./...
Expand Down
24 changes: 0 additions & 24 deletions bundle/bundle.Dockerfile

This file was deleted.

Loading