Skip to content

Commit

Permalink
Merge pull request #36 from jonmosco/kubeon_off_cleanup
Browse files Browse the repository at this point in the history
remove deprecation and add CHANGELOG placeholder fixes #34
  • Loading branch information
jonmosco committed Feb 21, 2018
2 parents fee2880 + 8d562a9 commit 68bf82f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 28 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
### kube-ps1 project CHANGELOG
43 changes: 15 additions & 28 deletions kube-ps1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

# Default values for the prompt
# Override these values in ~/.zshrc or ~/.bashrc
KUBE_PS1_BINARY="${KUBE_PS1_BINARY=kubectl}"
KUBE_PS1_BINARY="${KUBE_PS1_BINARY:-kubectl}"
KUBE_PS1_SYMBOL_ENABLE="${KUBE_PS1_SYMBOL_ENABLE:-true}"
KUBE_PS1_SYMBOL_DEFAULT=${KUBE_PS1_SYMBOL_DEFAULT:-$'\u2388 '}
KUBE_PS1_SYMBOL_USE_IMG="${KUBE_PS1_SYMBOL_USE_IMG:-false}"
Expand Down Expand Up @@ -232,11 +232,17 @@ _kube_ps1_file_newer_than() {
}

_kube_ps1_update_cache() {
local conf

if ! _kube_ps1_enabled; then
return
fi

local conf
if ! _kube_ps1_binary_check "${KUBE_PS1_BINARY}"; then
KUBE_PS1_CONTEXT="BINARY-N/A"
KUBE_PS1_NAMESPACE="N/A"
return
fi

if [[ "${KUBECONFIG}" != "${KUBE_PS1_KUBECONFIG_CACHE}" ]]; then
KUBE_PS1_KUBECONFIG_CACHE=${KUBECONFIG}
Expand Down Expand Up @@ -269,12 +275,6 @@ _kube_ps1_get_context_ns() {
KUBE_PS1_LAST_TIME=$EPOCHSECONDS
fi

if ! _kube_ps1_binary_check "${KUBE_PS1_BINARY}"; then
KUBE_PS1_CONTEXT="BINARY-N/A"
KUBE_PS1_NAMESPACE="N/A"
return
fi

KUBE_PS1_CONTEXT="$(${KUBE_PS1_BINARY} config current-context 2>/dev/null)"
if [[ -z "${KUBE_PS1_CONTEXT}" ]]; then
KUBE_PS1_CONTEXT="N/A"
Expand All @@ -290,7 +290,7 @@ _kube_ps1_get_context_ns() {
# Set shell options
_kube_ps1_shell_settings

_kube_ps1_on_usage() {
_kubeon_usage() {
cat <<"EOF"
Toggle kube-ps1 prompt on
Expand All @@ -303,7 +303,7 @@ With no arguments, turn off kube-ps1 status for this shell instance (default).
EOF
}

_kube_ps1_off_usage() {
_kubeoff_usage() {
cat <<"EOF"
Toggle kube-ps1 prompt off
Expand All @@ -316,43 +316,31 @@ With no arguments, turn off kube-ps1 status for this shell instance (default).
EOF
}

# TODO: remove this alias on Oct-01-2018
kubeon() {
# echo "deprecated $0 command will be removed on Oct-01-2018" >&2
kube_ps1_on "$@"
}

kubeoff() {
# echo "deprecated $0 command will be removed on Oct-01-2018" >&2
kube_ps1_off "$@"
}

kube_ps1_on() {
if [[ "$#" -eq 0 ]]; then
KUBE_PS1_ENABLED=on
elif [[ "${1}" == '-h' || "${1}" == '--help' ]]; then
_kube_ps1_on_usage
_kubeon_usage
elif [[ "${1}" == '-g' || "${1}" == '--global' ]]; then
rm -f "${KUBE_PS1_DISABLE_PATH}"
else
echo -e "error: unrecognized flag ${1}\\n"
_kube_ps1_on_usage
_kubeon_usage
return
fi
}


kube_ps1_off() {
kubeoff() {
if [[ "$#" -eq 0 ]]; then
KUBE_PS1_ENABLED=off
elif [[ "${1}" == '-h' || "${1}" == '--help' ]]; then
_kube_ps1_off_usage
_kubeoff_usage
elif [[ "${1}" == '-g' || "${1}" == '--global' ]]; then
mkdir -p "$(dirname $KUBE_PS1_DISABLE_PATH)"
touch "${KUBE_PS1_DISABLE_PATH}"
else
echo -e "error: unrecognized flag ${1}\\n"
_kube_ps1_off_usage
_kubeoff_usage
return
fi
}
Expand All @@ -367,7 +355,6 @@ _kube_ps1_enabled() {
}

# Build our prompt
# TODO: consider renaming to kube_ps1_prompt...
kube_ps1() {
if ! _kube_ps1_enabled; then
return
Expand Down

0 comments on commit 68bf82f

Please sign in to comment.