Skip to content

Commit

Permalink
Add dev script (#460)
Browse files Browse the repository at this point in the history
* Add dev script

* Clean up.

* Add +x to dev.sh
  • Loading branch information
smcclem authored Feb 28, 2023
1 parent 413ec4e commit 6f09d18
Show file tree
Hide file tree
Showing 2 changed files with 589 additions and 6 deletions.
56 changes: 50 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,23 @@ else
GOBIN=$(shell go env GOBIN)
endif

# Use docker if available. Otherwise default to podman.
# Override choice by setting CONTAINER_COMMAND
CHECK_DOCKER_RC=$(shell docker -v > /dev/null 2>&1; echo $$?)
ifneq (0, $(CHECK_DOCKER_RC))
CONTAINER_COMMAND ?= podman
# Setup parameters for TLS verify, default if unspecified is true
ifeq (false, $(TLS_VERIFY))
PODMAN_SKIP_TLS_VERIFY="--tls-verify=false"
SKIP_TLS_VERIFY=--skip-tls
else
TLS_VERIFY ?= true
PODMAN_SKIP_TLS_VERIFY="--tls-verify=true"
endif
else
CONTAINER_COMMAND ?= docker
endif

# Setting SHELL to bash allows bash commands to be executed by recipes.
# This is a requirement for 'setup-envtest.sh' in the test target.
# Options are set to exit when a recipe line exits non-zero or a piped command fails.
Expand Down Expand Up @@ -119,6 +136,18 @@ OPM = $(shell which opm)
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

.PHONY: setup
setup: ## Install Operator SDK if necessary.
./scripts/installers/install-operator-sdk.sh ${OPERATOR_SDK_RELEASE_VERSION}
Expand Down Expand Up @@ -224,19 +253,19 @@ docker-login: ## Log in to a Docker registry.

.PHONY: docker-build
docker-build: test ## Build docker image with the manager.
docker build -t ${IMG} .
$(CONTAINER_COMMAND) build -t ${IMG} .

.PHONY: docker-push
docker-push: ## Push docker image with the manager.
docker push ${IMG}
$(CONTAINER_COMMAND) push $(PODMAN_SKIP_TLS_VERIFY) ${IMG}

.PHONY: bundle-build
bundle-build: ## Build the bundle image.
docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) .
$(CONTAINER_COMMAND) build -f bundle.Dockerfile -t $(BUNDLE_IMG) .

.PHONY: bundle-push
bundle-push: docker-login ## Push the bundle image.
docker push "${PUBLISH_REGISTRY}/${BUNDLE_IMG}"
bundle-push: ## Push the bundle image.
$(CONTAINER_COMMAND) push $(PODMAN_SKIP_TLS_VERIFY) "${PUBLISH_REGISTRY}/${BUNDLE_IMG}"

build-manifest: setup-manifest
./scripts/build-manifest.sh --image "${PUBLISH_REGISTRY}/${OPERATOR_IMAGE}" --target "${RELEASE_TARGET}"
Expand Down Expand Up @@ -288,8 +317,23 @@ bundle-push-podman:
build-catalog:
opm index add --bundles "${BUNDLE_IMG}" --tag "${CATALOG_IMG}"

push-catalog: docker-login
push-catalog:
podman push --format=docker "${CATALOG_IMG}"

push-pipeline-catalog:
podman push --format=docker "${CATALOG_IMG}"

# 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
.PHONY: catalog-build
catalog-build: opm ## Build a catalog image.
$(OPM) index add $(SKIP_TLS_VERIFY) --container-tool $(CONTAINER_COMMAND) --mode semver --tag $(CATALOG_IMG) --bundles $(BUNDLE_IMGS) $(FROM_INDEX_OPT) --permissive

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

dev:
./scripts/dev.sh all
Loading

0 comments on commit 6f09d18

Please sign in to comment.