Skip to content

Commit

Permalink
[template] Wait some time for stdin
Browse files Browse the repository at this point in the history
Due to kubectl race condition with attaching stdin,
we should wait some time for it
  • Loading branch information
Dominik Rosiek authored and sumo-drosiek committed Dec 23, 2020
1 parent ceaaf24 commit e6305a2
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/commands/template
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

0 comments on commit e6305a2

Please sign in to comment.