From 18a130b4c6debbadeadd17e6415a1ed02cc574c8 Mon Sep 17 00:00:00 2001 From: Joshua B Date: Mon, 20 Sep 2021 15:10:34 -0600 Subject: [PATCH] Tpl sed heredoc (#22) * replace sed with heredoc * add dry_run to log-vars --- bin/github | 2 +- bin/heredoc_tpl | 28 ++++++++++++++++++++++++++++ bin/kube_tools | 6 +++--- k8s/docmark-pages-deploy.tpl.yml | 2 +- makefiles/Shipkit-main.make | 2 ++ tests/sandbox/heredoc.yml | 6 ++---- 6 files changed, 37 insertions(+), 9 deletions(-) create mode 100755 bin/heredoc_tpl diff --git a/bin/github b/bin/github index c0884c2..7d6cb67 100755 --- a/bin/github +++ b/bin/github @@ -24,7 +24,7 @@ function github.create_release { local body=$(cat "$BUILD_DIR/CHANGELOG_RELEASE.md") local body_esc=`escape_json_string "$body"` -## LEAVE THIS INDENT, her docs needs to to look this way +## LEAVE THIS INDENT, heredoc needs to to look this way local api_data=$(cat < "$processedTpl" + + echo "$processedTpl" +} + diff --git a/bin/kube_tools b/bin/kube_tools index 1e6b187..8a2f1f7 100755 --- a/bin/kube_tools +++ b/bin/kube_tools @@ -5,7 +5,7 @@ set -e source "$(dirname "${BASH_SOURCE[0]}")"/core/main core.import "init_env" -core.import "sed_tpl" +core.import "heredoc_tpl" core.import "dotenv" # --- @@ -14,8 +14,8 @@ core.import "dotenv" # --- function kube.process_tpl { # set the variables in BUILD_ENV so we can build the sed replacement for templates - dotenv.load "build/make/makefile${MAKELEVEL}.env" - sed_tpl "$1" "build/kube" + # dotenv.load "build/make/makefile${MAKELEVEL}.env" + heredoc_tpl "$1" "build/kube" } ### diff --git a/k8s/docmark-pages-deploy.tpl.yml b/k8s/docmark-pages-deploy.tpl.yml index 98d3043..b94eb05 100644 --- a/k8s/docmark-pages-deploy.tpl.yml +++ b/k8s/docmark-pages-deploy.tpl.yml @@ -1,7 +1,7 @@ # kubernetes deployment for pages generated with docmark. # container uses env variables to download git project, build the docs and then start a nginx webserver # sets up ingress-nginx services and uses default tls cert that was setup for it. -# use the sed_tpl to process this template for example `apply_tpl build/bin/kube_templates/.tpl.yml` +# use the heredoc_tpl to process this template for example `apply_tpl build/bin/kube_templates/.tpl.yml` apiVersion: apps/v1 kind: Deployment metadata: diff --git a/makefiles/Shipkit-main.make b/makefiles/Shipkit-main.make index 4133372..f1e7091 100644 --- a/makefiles/Shipkit-main.make +++ b/makefiles/Shipkit-main.make @@ -8,6 +8,7 @@ export BUILD_DIR ?= build # make a unique makefile using MAKELEVEL, which is incrmented for each make subprocess. # so if make calls a make target it doesn't collide, they can be different based on whats passed for DBMS for example export MAKE_ENV_FILE ?= $(BUILD_DIR)/make/makefile$(MAKELEVEL).env +# $(info MAKE_ENV_FILE: $(MAKE_ENV_FILE)) SHELL_VARS += VERBOSE_LOG BUILD_DIR MAKE_ENV_FILE DBMS env dry_run #shell doesn't get the exported vars so we need to spin the ones we want, which should be in BUILD_VARS @@ -67,6 +68,7 @@ FORCE: ## list the BUILD_VARS in the build/make env log-vars: FORCE + printf "$(ccyan)dry_run$(creset) = $(dry_run)\n" printf "$(culine)Variable:\n\n$(creset)" for v in $(sort $(BUILD_VARS)); do printf "$(ccyan)$$v $(creset)=$(cbold) $${!v:-} $(creset)\n" diff --git a/tests/sandbox/heredoc.yml b/tests/sandbox/heredoc.yml index 07da79f..dc7abfc 100644 --- a/tests/sandbox/heredoc.yml +++ b/tests/sandbox/heredoc.yml @@ -1,7 +1,5 @@ -# kubernetes deployment for pages generated with docmark. -# container uses env variables to download git project, build the docs and then start a nginx webserver -# sets up ingress-nginx services and uses default tls cert that was setup for it. -# use the sed_tpl to process this template for example `echo foo` +# Sample stuff + `tags=$(git tag -l --sort=-version:refname) echo "${tags[@]}" echo buzz