Skip to content

Commit

Permalink
Refactor j2 calling convention, always pass .env file path explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
mrnicegyu11 committed Dec 18, 2024
1 parent 43f7479 commit c8397fe
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 45 deletions.
4 changes: 2 additions & 2 deletions scripts/common.Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,13 @@ venv: $(REPO_BASE_DIR)/.venv/bin/activate ## Creates a python virtual environmen
ifeq ($(shell test -f j2cli_customization.py && echo -n yes),yes)
define jinja
$(REPO_BASE_DIR)/.venv/bin/j2 --format=env $(1) .env -o $(2) --customize j2cli_customization.py
$(REPO_BASE_DIR)/.venv/bin/j2 --format=env $(1) $(2) -o $(3) --customize j2cli_customization.py
endef
else
define jinja
$(REPO_BASE_DIR)/.venv/bin/j2 --format=env $(1) .env -o $(2)
$(REPO_BASE_DIR)/.venv/bin/j2 --format=env $(1) $(2) -o $(3)
endef
endif
Expand Down
2 changes: 1 addition & 1 deletion services/maintenance-page/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ up-master: up

.PHONY: docker-compose.yml
docker-compose.yml: .venv .env
@$(call jinja, docker-compose.yml.j2, docker-compose.yml.unlinted) && \
@$(call jinja, docker-compose.yml.j2, .env, docker-compose.yml.unlinted) && \
$(_yq) docker-compose.yml.unlinted > docker-compose.yml; \
rm docker-compose.yml.unlinted >/dev/null 2>&1;

Expand Down
10 changes: 5 additions & 5 deletions services/monitoring/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ ${TEMP_COMPOSE}-local: docker-compose.yml docker-compose.letsencrypt.dns.yml con
@${REPO_BASE_DIR}/scripts/docker-stack-config.bash -e .env $< docker-compose.letsencrypt.dns.yml > $@

docker-compose.yml: docker-compose.yml.j2 .env .venv pgsql_query_exporter_config.yaml
$(call jinja,$<,$@)
$(call jinja,$<,.env,$@)

.PHONY: update.grafana.pwd
update.grafana.pwd: .env ## Change grafana pwd
Expand All @@ -101,7 +101,7 @@ grafana-import: grafana/assets .venv ## Imports AND OVERWRITES the remote grafan

.PHONY: config.grafana.dashboards
config.grafana.dashboards: grafana/templates-provisioning/dashboards/simcore/Metrics-dashboard.json.j2 .venv #Configure dashboards for aws or dalco clusters
$(call jinja, $<, grafana/provisioning/dashboards/simcore/Metrics-dashboard.json)
$(call jinja, $<, .env, grafana/provisioning/dashboards/simcore/Metrics-dashboard.json)

.PHONY: config.monitoring
config.monitoring: grafana/template-config.monitoring ${REPO_CONFIG_LOCATION}
Expand Down Expand Up @@ -133,7 +133,7 @@ config.prometheus.ceph.simcore: ${REPO_CONFIG_LOCATION} .venv
@set -o allexport; \
source $<; \
set +o allexport; \
$(call jinja, prometheus/prometheus-ceph.yml.j2, prometheus/prometheus-ceph.yml); \
$(call jinja, prometheus/prometheus-ceph.yml.j2, .env, prometheus/prometheus-ceph.yml); \
cat prometheus/prometheus-base.yml | $(_yq) '. *+ load("prometheus/prometheus-simcore.yml")' | cat | \
$(_yq) '. *+ load("prometheus/prometheus-ceph.yml")' > prometheus/prometheus.yml; \
envsubst < prometheus/prometheus.yml > prometheus/prometheus.temp.yml; \
Expand All @@ -148,10 +148,10 @@ config.prometheus: ${REPO_CONFIG_LOCATION} .venv
mv prometheus/prometheus.temp.yml prometheus/prometheus.yml

pgsql_query_exporter_config.yaml: pgsql_query_exporter_config.yaml.j2 ${REPO_CONFIG_LOCATION} .env .venv
$(call jinja, $<, $@);
$(call jinja, $<, .env, $@);

smokeping_prober_config.yaml: smokeping_prober_config.yaml.j2 ${REPO_CONFIG_LOCATION} .env .venv
$(call jinja, $<, $@);
$(call jinja, $<, .env, $@);

.PHONY: grafana/assets
grafana/assets: ${REPO_CONFIG_LOCATION}
Expand Down
7 changes: 0 additions & 7 deletions services/monitoring/grafana-image-renderer/README.md

This file was deleted.

25 changes: 0 additions & 25 deletions services/monitoring/grafana-image-renderer/config.json

This file was deleted.

2 changes: 1 addition & 1 deletion services/redis-commander/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ ${TEMP_COMPOSE}-letsencrypt-dns: docker-compose.yml docker-compose.letsencrypt.d

config.json: config.json.j2 .env .venv
# generate $@
@$(call jinja, $<, $@)
@$(call jinja, $<, .env, $@)
# validate and format $@
@cat $@ | jq > /dev/null
2 changes: 1 addition & 1 deletion services/registry/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ up-public: up-dalco
# Helpers -------------------------------------------------

docker-compose.yml: docker-compose.yml.j2 .venv .env
@$(call jinja, $<, $@)
@$(call jinja, $<, .env, $@)

.PHONY: ${TEMP_COMPOSE}-local
${TEMP_COMPOSE}-local: docker-compose.yml docker-compose.self-signed.yml .env
Expand Down
4 changes: 2 additions & 2 deletions services/traefik/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,13 @@ ${TEMP_COMPOSE}-master: docker-compose.yml docker-compose.master.yml .env

.PHONY: docker-compose.letsencrypt.dns.yml
docker-compose.letsencrypt.dns.yml: .venv .env
@$(call jinja, docker-compose.letsencrypt.dns.yml.j2, docker-compose.letsencrypt.dns.yml.unlinted) && \
@$(call jinja, docker-compose.letsencrypt.dns.yml.j2, .env, docker-compose.letsencrypt.dns.yml.unlinted) && \
$(_yq) docker-compose.letsencrypt.dns.yml.unlinted > docker-compose.letsencrypt.dns.yml; \
rm docker-compose.letsencrypt.dns.yml.unlinted >/dev/null 2>&1;

.PHONY: docker-compose.yml
docker-compose.yml: traefik_dynamic_config.yml .venv .env
@$(call jinja, docker-compose.yml.j2, docker-compose.yml.unlinted) && \
@$(call jinja, docker-compose.yml.j2, .env, docker-compose.yml.unlinted) && \
$(_yq) docker-compose.yml.unlinted > docker-compose.yml; \
rm docker-compose.yml.unlinted >/dev/null 2>&1;

Expand Down
2 changes: 1 addition & 1 deletion services/vendors/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ up-local: up

.PHONY: docker-compose.yml
docker-compose.yml: .venv .env
@$(call jinja, docker-compose.yml.j2, docker-compose.yml.unlinted) && \
@$(call jinja, docker-compose.yml.j2, .env, docker-compose.yml.unlinted) && \
$(_yq) docker-compose.yml.unlinted > docker-compose.yml; \
rm docker-compose.yml.unlinted >/dev/null 2>&1;

Expand Down

0 comments on commit c8397fe

Please sign in to comment.