|
1 | 1 | export NAME=capi-providers-cpprovider |
2 | 2 | export NAMESPACE=cozy-cluster-api |
3 | 3 |
|
| 4 | +include ../../../hack/common-envs.mk |
4 | 5 | include ../../../hack/package.mk |
| 6 | + |
| 7 | +.PHONY: image update |
| 8 | + |
| 9 | +# COMMIT is the upstream master SHA pinned in the Dockerfile and reused |
| 10 | +# below for the kustomize re-render. Keep them in lockstep when bumping. |
| 11 | +COMMIT = $(shell awk -F= '/^ARG COMMIT=/{print $$2}' images/cluster-api-control-plane-provider-kamaji/Dockerfile) |
| 12 | +IMAGE_BASE = $(REGISTRY)/cluster-api-control-plane-provider-kamaji |
| 13 | +IMAGE_TAG = master-$(shell echo $(COMMIT) | cut -c1-7) |
| 14 | + |
| 15 | +image: |
| 16 | + docker buildx build images/cluster-api-control-plane-provider-kamaji \ |
| 17 | + --tag $(IMAGE_BASE):$(IMAGE_TAG) \ |
| 18 | + --tag $(IMAGE_BASE):$(IMAGE_TAG)-$(TAG) \ |
| 19 | + --cache-from type=registry,ref=$(IMAGE_BASE):latest \ |
| 20 | + --cache-to type=inline \ |
| 21 | + --metadata-file images/cluster-api-control-plane-provider-kamaji.json \ |
| 22 | + $(BUILDX_ARGS) |
| 23 | + digest=$$(yq e '."containerimage.digest"' images/cluster-api-control-plane-provider-kamaji.json -o json -r); \ |
| 24 | + IMG="$(IMAGE_BASE):$(IMAGE_TAG)@$$digest"; \ |
| 25 | + echo "$$IMG" > images/cluster-api-control-plane-provider-kamaji.tag; \ |
| 26 | + sed -i.bak -E "s|image: ghcr\.io/.+/cluster-api-control-plane-provider-kamaji:[^[:space:]]+|image: $$IMG|" files/control-plane-components.yaml; \ |
| 27 | + rm files/control-plane-components.yaml.bak; \ |
| 28 | + gzip -nc files/control-plane-components.yaml > files/components.gz |
| 29 | + rm -f images/cluster-api-control-plane-provider-kamaji.json |
| 30 | + |
| 31 | +# Refreshes files/control-plane-components.yaml + files/components.gz from |
| 32 | +# the upstream sources at the pinned COMMIT, leaving the manager image ref |
| 33 | +# pointing at our mirror. Use this when bumping COMMIT in the Dockerfile. |
| 34 | +# Requires `kustomize` on PATH. |
| 35 | +update: |
| 36 | + @command -v kustomize >/dev/null || { echo "kustomize required (https://kustomize.io)"; exit 1; } |
| 37 | + rm -rf .update-tmp |
| 38 | + mkdir .update-tmp |
| 39 | + curl -sSL "https://github.com/clastix/cluster-api-control-plane-provider-kamaji/archive/$(COMMIT).tar.gz" \ |
| 40 | + | tar -xzf - --strip=1 -C .update-tmp |
| 41 | + cd .update-tmp/config/manager && \ |
| 42 | + kustomize edit set image controller=$(IMAGE_BASE):$(IMAGE_TAG) |
| 43 | + kustomize build .update-tmp/config/default > files/control-plane-components.yaml |
| 44 | + gzip -nc files/control-plane-components.yaml > files/components.gz |
| 45 | + rm -rf .update-tmp |
0 commit comments