Skip to content

Commit

Permalink
add fix for jonmosco#97. return code added to caching function
Browse files Browse the repository at this point in the history
  • Loading branch information
jonmosco committed Jul 17, 2019
1 parent 3e3bfa9 commit 623fe07
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion kube-ps1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ _kube_ps1_file_newer_than() {
_kube_ps1_update_cache() {
[[ "${KUBE_PS1_ENABLED}" == "off" ]] && return

local return_code=$?

if ! _kube_ps1_binary_check "${KUBE_PS1_BINARY}"; then
# No ability to fetch context/namespace; display N/A.
KUBE_PS1_CONTEXT="BINARY-N/A"
Expand All @@ -223,14 +225,16 @@ _kube_ps1_update_cache() {
return
fi
done

return $return_code
}

_kube_ps1_get_context() {
if [[ "${KUBE_PS1_CONTEXT_ENABLE}" == true ]]; then
KUBE_PS1_CONTEXT="$(${KUBE_PS1_BINARY} config current-context 2>/dev/null)"
# Set namespace to 'N/A' if it is not defined
KUBE_PS1_CONTEXT="${KUBE_PS1_CONTEXT:-N/A}"

if [[ ! -z "${KUBE_PS1_CLUSTER_FUNCTION}" ]]; then
KUBE_PS1_CONTEXT=$($KUBE_PS1_CLUSTER_FUNCTION $KUBE_PS1_CONTEXT)
fi
Expand Down

0 comments on commit 623fe07

Please sign in to comment.