mirror of
https://github.com/ahmetb/kubectx.git
synced 2025-08-09 11:17:44 +00:00
Incorporate utils.bash into each executable to help simplify packaging
for Linux and other platforms. This adds to PR #32 remove unused functions
This commit is contained in:
parent
8da629d98e
commit
b188f4da88
@ -93,7 +93,7 @@ This command will set up bash/zsh/fish completion scripts automatically.
|
||||
Since `kubectx`/`kubens` are written in Bash, you should be able to instal
|
||||
them to any POSIX environment that has Bash installed.
|
||||
|
||||
- Download the `kubectx`, `kubens` and `utils.bash` scripts.
|
||||
- Download the `kubectx`, and `kubens` scripts.
|
||||
- Either:
|
||||
- save them all to somewhere in your `PATH`,
|
||||
- or save them to a directory, then create symlinks to `kubectx`/`kubens` from
|
||||
|
17
kubectx
17
kubectx
@ -21,15 +21,6 @@
|
||||
set -eou pipefail
|
||||
IFS=$'\n\t'
|
||||
|
||||
SCRIPT_DIR="$(dirname "$( readlink -f "${0}" 2>/dev/null || \
|
||||
python -c "import os,sys; print(os.path.realpath(sys.argv[1]))" "${0}" )")"
|
||||
|
||||
if [[ -f "${SCRIPT_DIR}/utils.bash" ]]; then
|
||||
source "${SCRIPT_DIR}/utils.bash"
|
||||
else
|
||||
source "${SCRIPT_DIR}/../include/utils.bash"
|
||||
fi
|
||||
|
||||
KUBECTX="${HOME}/.kube/kubectx"
|
||||
|
||||
usage() {
|
||||
@ -44,6 +35,14 @@ EOF
|
||||
exit 1
|
||||
}
|
||||
|
||||
current_context() {
|
||||
kubectl config view -o=jsonpath='{.current-context}'
|
||||
}
|
||||
|
||||
get_contexts() {
|
||||
kubectl config get-contexts -o=name | sort -n
|
||||
}
|
||||
|
||||
list_contexts() {
|
||||
set -u pipefail
|
||||
local cur="$(current_context)"
|
||||
|
17
kubens
17
kubens
@ -21,15 +21,6 @@
|
||||
set -eou pipefail
|
||||
IFS=$'\n\t'
|
||||
|
||||
SCRIPT_DIR="$(dirname "$( readlink -f "${0}" 2>/dev/null || \
|
||||
python -c "import os,sys; print(os.path.realpath(sys.argv[1]))" "${0}" )")"
|
||||
|
||||
if [[ -f "${SCRIPT_DIR}/utils.bash" ]]; then
|
||||
source "${SCRIPT_DIR}/utils.bash"
|
||||
else
|
||||
source "${SCRIPT_DIR}/../include/utils.bash"
|
||||
fi
|
||||
|
||||
KUBENS_DIR="${HOME}/.kube/kubens"
|
||||
|
||||
usage() {
|
||||
@ -53,6 +44,14 @@ current_namespace() {
|
||||
fi
|
||||
}
|
||||
|
||||
current_context() {
|
||||
kubectl config view -o=jsonpath='{.current-context}'
|
||||
}
|
||||
|
||||
get_namespaces() {
|
||||
kubectl get namespaces -o=jsonpath='{range .items[*].metadata.name}{@}{"\n"}{end}'
|
||||
}
|
||||
|
||||
namespace_file() {
|
||||
local ctx="${1}"
|
||||
echo "${KUBENS_DIR}/${ctx}"
|
||||
|
11
utils.bash
11
utils.bash
@ -1,11 +0,0 @@
|
||||
current_context() {
|
||||
kubectl config view -o=jsonpath='{.current-context}'
|
||||
}
|
||||
|
||||
get_contexts() {
|
||||
kubectl config get-contexts -o=name | sort -n
|
||||
}
|
||||
|
||||
get_namespaces() {
|
||||
kubectl get namespaces -o=jsonpath='{range .items[*].metadata.name}{@}{"\n"}{end}'
|
||||
}
|
Loading…
Reference in New Issue
Block a user