Skip to content

Commit 4ee5b4e

Browse files
authored
Use read command to test if there is any data on stdin & redirect to stderr (#77)
* Use read command to test if there is any data on stdin * Redirect messages to stderr * Add echo_stderr function * Fix style, change echo_stderr to echoerr
1 parent d6c5b95 commit 4ee5b4e

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/commands/template

+8-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ function print_help() {
44
echo "K8S template generator"
55
}
66

7+
function echoerr() {
8+
echo "${1}" >&2
9+
}
10+
711
readonly arg=${1}
812

913
if [[ "${arg}" == "--help" ]]; then
@@ -17,15 +21,15 @@ readonly REPO_URL="${REPO_URL:-https://sumologic.github.io/sumologic-kubernetes-
1721
# Take data from stdin if available and put into tmpfile
1822
tmpfile="$(mktemp /tmp/values.yaml.XXXXXX)"
1923
extra_params=''
20-
if [ ! -t 0 ]; then
24+
if [ ! read -t 0 ]; then
2125
cat <&0 > "${tmpfile}"
2226
extra_params="-f${tmpfile}"
2327
fi
2428

25-
echo '# Add sumologic repository'
29+
echoerr '# Add sumologic repository'
2630
helm repo add sumologic "${REPO_URL}" 1>/dev/null 2>&1
27-
echo '# Update repository'
31+
echoerr '# Update repository'
2832
helm repo update 1>/dev/null 2>&1
29-
echo '# Generating template'
33+
echoerr '# Generating template'
3034
helm template "${REPO_PATH}" ${extra_params} "$@" 2>&1 | grep -vE '^manifest_sorter.go'
3135
rm "${tmpfile}"

0 commit comments

Comments
 (0)