From f1e03b10bd69382a4f5ac7e149907b3f3d99ffa3 Mon Sep 17 00:00:00 2001 From: Peter Levart Date: Tue, 12 Dec 2023 11:25:33 +0100 Subject: [PATCH] Use ifeq in common Makefile instead of a separate Makefile.podman --- Makefile | 50 +++++++++++++++++++++++++++++-------------------- Makefile.podman | 10 ---------- 2 files changed, 30 insertions(+), 30 deletions(-) delete mode 100644 Makefile.podman diff --git a/Makefile b/Makefile index 718bf6675..1ba65e5a7 100644 --- a/Makefile +++ b/Makefile @@ -6,16 +6,26 @@ CT_IMAGE = quay.io/helmpack/chart-testing:v3.7.1 KNOWN_TARGETS=helm HELM?=helm-docker CT?=ct-docker -DOCKER ?= docker -DOCKER_USER_OPTION ?= --user $(shell id -u):$(shell id -g) -DOCKER_VOLUME_OPTION_SUFFIX ?= +CONTAINER ?= docker + +ifeq ($(CONTAINER),docker) + CONTAINER_USER_OPTION = --user $(shell id -u):$(shell id -g) + CONTAINER_VOLUME_OPTION_SUFFIX = +else + ifeq ($(CONTAINER),podman) + CONTAINER_USER_OPTION = + CONTAINER_VOLUME_OPTION_SUFFIX = :z + else + $(error CONTAINER values currently supported are: docker, podman) + endif +endif helm-docker: mkdir -p .helm/cache - $(DOCKER) run --rm --name helm-exec \ - $(DOCKER_USER_OPTION) \ - --volume "$(shell pwd):/helm-charts$(DOCKER_VOLUME_OPTION_SUFFIX)" \ - --volume "$(shell pwd)/.github/ci/helm-repos.yaml:/helm-charts/.helm/config/repositories.yaml$(DOCKER_VOLUME_OPTION_SUFFIX)" \ + $(CONTAINER) run --rm --name helm-exec \ + $(CONTAINER_USER_OPTION) \ + --volume "$(shell pwd):/helm-charts$(CONTAINER_VOLUME_OPTION_SUFFIX)" \ + --volume "$(shell pwd)/.github/ci/helm-repos.yaml:/helm-charts/.helm/config/repositories.yaml$(CONTAINER_VOLUME_OPTION_SUFFIX)" \ -w /helm-charts \ -e HELM_CACHE_HOME=/helm-charts/.helm/cache \ -e HELM_CONFIG_HOME=/helm-charts/.helm/config \ @@ -29,10 +39,10 @@ helm-local: ct-docker: mkdir -p .helm/cache - $(DOCKER) run --rm --name helm-exec \ - $(DOCKER_USER_OPTION) \ - --volume "$(shell pwd):/helm-charts$(DOCKER_VOLUME_OPTION_SUFFIX)" \ - --volume "$(shell pwd)/.github/ci/helm-repos.yaml:/helm-charts/.helm/config/repositories.yaml$(DOCKER_VOLUME_OPTION_SUFFIX)" \ + $(CONTAINER) run --rm --name helm-exec \ + $(CONTAINER_USER_OPTION) \ + --volume "$(shell pwd):/helm-charts$(CONTAINER_VOLUME_OPTION_SUFFIX)" \ + --volume "$(shell pwd)/.github/ci/helm-repos.yaml:/helm-charts/.helm/config/repositories.yaml$(CONTAINER_VOLUME_OPTION_SUFFIX)" \ -w /helm-charts \ -e HELM_CACHE_HOME=/helm-charts/.helm/cache \ -e HELM_CONFIG_HOME=/helm-charts/.helm/config \ @@ -126,18 +136,18 @@ init: # CMD="repo index --url ${URL} --merge index.yaml ." $(MAKE) $(HELM) gen-docs: - $(DOCKER) run --rm \ - $(DOCKER_USER_OPTION) \ - --volume "$(shell pwd):/helm-charts$(DOCKER_VOLUME_OPTION_SUFFIX)" \ + $(CONTAINER) run --rm \ + $(CONTAINER_USER_OPTION) \ + --volume "$(shell pwd):/helm-charts$(CONTAINER_VOLUME_OPTION_SUFFIX)" \ -w /helm-charts \ $(HELM_DOCS_IMAGE) \ helm-docs # Synchronize alerting rules in charts/victoria-metrics-k8s-stack/templates/rules sync-rules: - $(DOCKER) run --rm \ - $(DOCKER_USER_OPTION) \ - --volume "$(shell pwd)/charts/victoria-metrics-k8s-stack:/k8s-stack$(DOCKER_VOLUME_OPTION_SUFFIX)" \ + $(CONTAINER) run --rm \ + $(CONTAINER_USER_OPTION) \ + --volume "$(shell pwd)/charts/victoria-metrics-k8s-stack:/k8s-stack$(CONTAINER_VOLUME_OPTION_SUFFIX)" \ -w /k8s-stack/hack/ \ $(PYTHON_IMAGE) sh -c "\ pip3 install --no-cache-dir --no-build-isolation -r requirements.txt --user && python3 sync_rules.py \ @@ -145,9 +155,9 @@ sync-rules: # Synchronize grafana dashboards in charts/victoria-metrics-k8s-stack/templates/grafana/dashboards sync-dashboards: - $(DOCKER) run --rm \ - $(DOCKER_USER_OPTION) \ - --volume "$(shell pwd)/charts/victoria-metrics-k8s-stack:/k8s-stack$(DOCKER_VOLUME_OPTION_SUFFIX)" \ + $(CONTAINER) run --rm \ + $(CONTAINER_USER_OPTION) \ + --volume "$(shell pwd)/charts/victoria-metrics-k8s-stack:/k8s-stack$(CONTAINER_VOLUME_OPTION_SUFFIX)" \ -w /k8s-stack/hack/ \ $(PYTHON_IMAGE) sh -c "\ pip3 install --no-cache-dir --no-build-isolation -r requirements.txt --user && python3 sync_grafana_dashboards.py \ diff --git a/Makefile.podman b/Makefile.podman deleted file mode 100644 index 6a66eabb5..000000000 --- a/Makefile.podman +++ /dev/null @@ -1,10 +0,0 @@ -# -# Use this file instead of Makefile to use rootless podman containers instead of docker: -# -# make -f Makefile.podman ... -# -DOCKER = podman -DOCKER_USER_OPTION = -DOCKER_VOLUME_OPTION_SUFFIX = :z - -include Makefile