Skip to content

Commit

Permalink
Makefile: add the REGISTRY_URL var
Browse files Browse the repository at this point in the history
this is needed to align with the registry/repo templating introduced for
airgapped scenario support.

While there, also drop the SEEDIMAGE_TAG: just use the common TAG for
the seedimage container image.

Signed-off-by: Francesco Giudici <[email protected]>
  • Loading branch information
fgiudici committed Aug 21, 2023
1 parent 158d42b commit 9a9ebfa
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Build chart for release
if: startsWith(github.ref, 'refs/tags/')
run: |
REPO=quay.io/costoolkit/elemental-operator REPO_SEEDIMAGE=quay.io/costoolkit/elemental-seedimage TAG=${GITHUB_REF##*/} make chart
REGISTRY_URL=quay.io/costoolkit REPO=elemental-operator REPO_SEEDIMAGE=elemental-seedimage TAG=${GITHUB_REF##*/} make chart
- name: Publish chart to release
uses: fnkr/github-action-ghr@v1
if: startsWith(github.ref, 'refs/tags/')
Expand All @@ -49,7 +49,7 @@ jobs:
TAG=$(helm show values ${{ steps.chart.outputs.chart_name }}|yq .image.tag)
if [ "$REPO" != "quay.io/costoolkit/elemental-operator-ci" ];then
echo "REPO on the built chart is not the expected value"
echo "Expected quay.io/costoolkit/elemental-operator but got $REPO"
echo "Expected quay.io/costoolkit/elemental-operator-ci but got $REPO"
exit 1
fi
- name: Test release chart values
Expand Down
38 changes: 23 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@ GIT_COMMIT?=$(shell git rev-parse HEAD)
GIT_COMMIT_SHORT?=$(shell git rev-parse --short HEAD)
GIT_TAG?=$(shell git describe --abbrev=0 --tags 2>/dev/null || echo "v0.0.0" )
TAG?=${GIT_TAG}-${GIT_COMMIT_SHORT}
REPO?=quay.io/costoolkit/elemental-operator-ci
REPO_REGISTER?=quay.io/costoolkit/elemental-register-ci
TAG_SEEDIMAGE?=${TAG}
REPO_SEEDIMAGE?=quay.io/costoolkit/seedimage-builder-ci
REPO?=elemental-operator-ci
REPO_REGISTER?=elemental-register-ci
REPO_SEEDIMAGE?=seedimage-builder-ci
REGISTRY_URL?=quay.io/coostoolkit
#REGISTRY_URL?=registry.opensuse.org/isv/rancher/elemental/dev/containers
ifneq ($(REGISTRY_URL),)
REGISTRY_HEADER := $(REGISTRY_URL)/
else
REGISTRY_HEADER := ""
endif

export ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
CHART_VERSION?=$(subst v,,$(GIT_TAG))
CHART?=$(shell find $(ROOT_DIR) -type f -name "elemental-operator-$(CHART_VERSION).tgz" -print)
Expand Down Expand Up @@ -91,7 +98,7 @@ build-docker-operator:
--build-arg "TAG=${GIT_TAG}" \
--build-arg "COMMIT=${GIT_COMMIT}" \
--build-arg "COMMITDATE=${COMMITDATE}" \
-t ${REPO}:${TAG} .
-t ${REGISTRY_HEADER}${REPO}:${TAG} .

.PHONY: build-docker-register
build-docker-register:
Expand All @@ -101,25 +108,25 @@ build-docker-register:
--build-arg "TAG=${GIT_TAG}" \
--build-arg "COMMIT=${GIT_COMMIT}" \
--build-arg "COMMITDATE=${COMMITDATE}" \
-t ${REPO_REGISTER}:${TAG} .
-t ${REGISTRY_HEADER}${REPO_REGISTER}:${TAG} .

.PHONY: build-docker-seedimage-builder
build-docker-seedimage-builder:
DOCKER_BUILDKIT=1 docker build \
-f Dockerfile.seedimage \
-t ${REPO_SEEDIMAGE}:${TAG} .
-t ${REGISTRY_HEADER}${REPO_SEEDIMAGE}:${TAG} .

.PHONY: build-docker-push-operator
build-docker-push-operator: build-docker-operator
docker push ${REPO}:${TAG}
docker push ${REGISTRY_HEADER}${REPO}:${TAG}

.PHONY: build-docker-push-register
build-docker-push-register: build-docker-register
docker push ${REPO_REGISTER}:${TAG}
docker push ${REGISTRY_HEADER}${REPO_REGISTER}:${TAG}

.PHONY: build-docker-push-seedimage-builder
build-docker-push-seedimage-builder: build-docker-seedimage-builder
docker push ${REPO_SEEDIMAGE}:${TAG}
docker push ${REGISTRY_HEADER}${REPO_SEEDIMAGE}:${TAG}

.PHONY: chart
chart:
Expand All @@ -130,8 +137,9 @@ chart:
cp -rf $(ROOT_DIR)/charts/operator $(ROOT_DIR)/build/operator
yq -i '.image.tag = "${TAG}"' $(ROOT_DIR)/build/operator/values.yaml
yq -i '.image.repository = "${REPO}"' $(ROOT_DIR)/build/operator/values.yaml
yq -i '.seedImage.tag = "${TAG_SEEDIMAGE}"' $(ROOT_DIR)/build/operator/values.yaml
yq -i '.seedImage.tag = "${TAG}"' $(ROOT_DIR)/build/operator/values.yaml
yq -i '.seedImage.repository = "${REPO_SEEDIMAGE}"' $(ROOT_DIR)/build/operator/values.yaml
yq -i '.registry_url = "${REGISTRY_URL}"' $(ROOT_DIR)/build/operator/values.yaml
helm package --version ${CHART_VERSION} --app-version ${GIT_TAG} -d $(ROOT_DIR)/build/ $(ROOT_DIR)/build/operator
rm -Rf $(ROOT_DIR)/build/operator

Expand Down Expand Up @@ -170,20 +178,20 @@ setup-full-cluster: build-docker-operator build-docker-seedimage-builder chart s
export BRIDGE_IP="172.18.0.1" && \
export CHART=$(CHART) && \
export CONFIG_PATH=$(E2E_CONF_FILE) && \
kind load docker-image --name $(CLUSTER_NAME) ${REPO}:${TAG} && \
kind load docker-image --name $(CLUSTER_NAME) ${REPO_SEEDIMAGE}:${TAG} && \
kind load docker-image --name $(CLUSTER_NAME) ${REGISTRY_HEADER}${REPO}:${TAG} && \
kind load docker-image --name $(CLUSTER_NAME) ${REGISTRY_HEADER}${REPO_SEEDIMAGE}:${TAG} && \
cd $(ROOT_DIR)/tests && $(GINKGO) -r -v --label-filter="do-nothing" ./e2e

kind-e2e-tests: build-docker-operator chart setup-kind
export CONFIG_PATH=$(E2E_CONF_FILE) && \
kind load docker-image --name $(CLUSTER_NAME) ${REPO}:${TAG}
kind load docker-image --name $(CLUSTER_NAME) ${REGISTRY_HEADER}${REPO}:${TAG}
$(MAKE) e2e-tests

# This builds the docker image, generates the chart, loads the image into the kind cluster and upgrades the chart to latest
# useful to test changes into the operator with a running system, without clearing the operator namespace
# thus losing any registration/inventories/os CRDs already created
reload-operator: build-docker-operator chart
kind load docker-image --name $(CLUSTER_NAME) ${REPO}:${TAG}
kind load docker-image --name $(CLUSTER_NAME) ${REGISTRY_HEADER}${REPO}:${TAG}
helm upgrade -n cattle-elemental-system elemental-operator $(CHART)

.PHONY: vendor
Expand Down

0 comments on commit 9a9ebfa

Please sign in to comment.