Skip to content

Commit

Permalink
Use ifeq in common Makefile instead of a separate Makefile.podman
Browse files Browse the repository at this point in the history
  • Loading branch information
plevart committed Dec 12, 2023
1 parent 6cf63e0 commit f1e03b1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 30 deletions.
50 changes: 30 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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 \
Expand Down Expand Up @@ -126,28 +136,28 @@ 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 \
"

# 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 \
Expand Down
10 changes: 0 additions & 10 deletions Makefile.podman

This file was deleted.

0 comments on commit f1e03b1

Please sign in to comment.