diff --git a/src/commands/template b/src/commands/template index b07d2a2a..c5c2e62b 100755 --- a/src/commands/template +++ b/src/commands/template @@ -17,19 +17,23 @@ fi readonly REPO_PATH="${REPO_PATH:-sumologic/sumologic}" readonly REPO_URL="${REPO_URL:-https://sumologic.github.io/sumologic-kubernetes-collection}" +readonly STDIN_WAIT_S="${STDIN_WAIT_S:10}" + +echoerr '# Add sumologic repository' +helm repo add sumologic "${REPO_URL}" 1>/dev/null 2>&1 +echoerr '# Update repository' +helm repo update 1>/dev/null 2>&1 # Take data from stdin if available and put into tmpfile tmpfile="$(mktemp /tmp/values.yaml.XXXXXX)" extra_params='' -if read -t 0; then +# Kubectl can take some time before stdin is available for reading +# thats why we check if just before it's required +if read -t "${STDIN_WAIT_S}"; then cat <&0 > "${tmpfile}" extra_params="-f${tmpfile}" fi -echoerr '# Add sumologic repository' -helm repo add sumologic "${REPO_URL}" 1>/dev/null 2>&1 -echoerr '# Update repository' -helm repo update 1>/dev/null 2>&1 echoerr '# Generating template' helm template "${REPO_PATH}" ${extra_params} "$@" 2>&1 | grep -vE '^manifest_sorter.go' rm "${tmpfile}"