Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor scripts to build bundle and catalog #119

Merged
merged 17 commits into from
Apr 29, 2021
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
11 changes: 11 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,24 @@ jobs:
with:
version: 2.3.1

- name: Install operator-sdk
run: |
RELEASE_VERSION=v1.6.1
curl -LO "https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/operator-sdk_linux_amd64"
chmod +x operator-sdk_linux_amd64 && sudo mkdir -p /usr/local/bin/ && sudo mv operator-sdk_linux_amd64 /usr/local/bin/operator-sdk

- name: build release
id: build_release
env:
VERSION: ${{ github.event.release.tag_name }}
IMAGE_TAG_BASE: streamnative/function-mesh
CATALOG_BRANCH_TAG: latest
run: |
make release
make docker-push
# convert vx.y.z to x.y.z because a valid semver is needed in creating the bundle
VERSION=$(echo $VERSION|cut -c 2-)
make docker-build image-push bundle bundle-build bundle-push catalog-build catalog-push

- name: Upload crd.yaml to release
uses: svenstaro/upload-release-action@v2
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,8 @@ bin
*.swo
*~
bundle*/

bundle
bundle.Dockerfile
index.Dockerfile*
index_build_*/
78 changes: 74 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
# Current Operator version
VERSION ?= v0.1.2
VERSION ?= 0.1.2
# Default image tag
DOCKER_REPO := $(if $(DOCKER_REPO),$(DOCKER_REPO),streamnative)
BUNDLE_IMG ?= function-mesh-controller-bundle:$(VERSION)
OPERATOR_IMG ?= ${DOCKER_REPO}/function-mesh:$(VERSION)
OPERATOR_IMG ?= ${DOCKER_REPO}/function-mesh:v$(VERSION)
OPERATOR_IMG_LATEST ?= ${DOCKER_REPO}/function-mesh:latest

# 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
# example.com/memcached-operator-bundle:$VERSION and example.com/memcached-operator-catalog:$VERSION.
IMAGE_TAG_BASE ?= ${DOCKER_REPO}/function-mesh

# 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)

GOOS := $(if $(GOOS),$(GOOS),linux)
GOARCH := $(if $(GOARCH),$(GOARCH),amd64)
GOENV := CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH)
Expand All @@ -22,7 +32,7 @@ endif
BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)

# Image URL to use all building/pushing image targets
IMG ?= streamnative/function-mesh:v0.1.1
IMG ?= ${DOCKER_REPO}/function-mesh-operator:v$(VERSION)
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:trivialVersions=true"

Expand Down Expand Up @@ -80,6 +90,10 @@ generate: controller-gen
docker-build: test
docker build . -t ${IMG}

# Push the docker image
image-push:
docker push ${IMG}

# find or download controller-gen
# download controller-gen if necessary
controller-gen:
Expand Down Expand Up @@ -125,6 +139,11 @@ bundle: manifests
bundle-build:
docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) .

.PHONY: bundle-push
bundle-push: ## Push the bundle image.
echo $(BUNDLE_IMG)
$(MAKE) image-push IMG=$(BUNDLE_IMG)

crd: manifests
$(KUSTOMIZE) build config/crd > manifests/crd.yaml

Expand All @@ -140,3 +159,54 @@ operator-docker-image: test
docker-push:
docker push $(OPERATOR_IMG)
docker push $(OPERATOR_IMG_LATEST)

.PHONY: opm
OPM = ./bin/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/download/v1.15.1/$${OS}-$${ARCH}-opm ;\
chmod +x $(OPM) ;\
}
else
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)

ifneq ($(origin CATALOG_BRANCH_TAG), undefined)
CATALOG_BRANCH_IMG ?= $(IMAGE_TAG_BASE)-catalog:$(CATALOG_BRANCH_TAG)
endif

# 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

# 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 --container-tool docker --mode semver --tag $(CATALOG_IMG) --bundles $(BUNDLE_IMGS) $(FROM_INDEX_OPT)
ifneq ($(origin CATALOG_BRANCH_TAG), undefined)
docker tag $(CATALOG_IMG) $(CATALOG_BRANCH_IMG)
endif

# Push the catalog image.
.PHONY: catalog-push
catalog-push: ## Push a catalog image.
$(MAKE) image-push IMG=$(CATALOG_IMG)
ifneq ($(origin CATALOG_BRANCH_TAG), undefined)
$(MAKE) image-push IMG=$(CATALOG_BRANCH_IMG)
endif
11 changes: 10 additions & 1 deletion PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,23 @@ projectName: function-mesh
repo: github.com/streamnative/function-mesh
resources:
- group: compute
controller: true
domain: streamnative.io
kind: FunctionMesh
path: github.com/streamnative/function-mesh/api/v1alpha1
version: v1alpha1
- group: compute
controller: true
domain: streamnative.io
kind: Source
path: github.com/streamnative/function-mesh/api/v1alpha1
version: v1alpha1
- group: compute
controller: true
domain: streamnative.io
kind: Sink
path: github.com/streamnative/function-mesh/api/v1alpha1
version: v1alpha1
version: 3-alpha
version: "3"
plugins:
go.sdk.operatorframework.io/v2-alpha: {}
15 changes: 0 additions & 15 deletions bundle.Dockerfile

This file was deleted.

This file was deleted.

This file was deleted.

13 changes: 0 additions & 13 deletions bundle/manifests/function-mesh-webhook-service_v1_service.yaml

This file was deleted.

Loading