mirror of
https://github.com/jimeh/dotfiles.git
synced 2026-02-19 13:46:41 +00:00
fix(zsh/kubernetes): improve password handling in docker-config-json function
This commit is contained in:
@@ -88,20 +88,19 @@ fi
|
|||||||
|
|
||||||
# docker-config-json SERVER USER [PASSWORD]
|
# docker-config-json SERVER USER [PASSWORD]
|
||||||
#
|
#
|
||||||
# Generate a `.dockerconfigjson` payload locally for registry auth, skipping
|
# Generate a `.dockerconfigjson` payload locally for registry auth. Password can
|
||||||
# `kubectl`. Prompts for the password when omitted in interactive shells.
|
# be passed as an argument, piped via stdin, or prompted for interactively.
|
||||||
docker-config-json() {
|
docker-config-json() {
|
||||||
local server="$1"
|
local server="$1"
|
||||||
local username="$2"
|
local username="$2"
|
||||||
local password="$3"
|
local password="$3"
|
||||||
|
|
||||||
if [[ -z "$password" ]]; then
|
if [[ -z "$password" ]]; then
|
||||||
if [[ -t 0 && -t 1 ]]; then
|
if [[ ! -t 0 ]]; then
|
||||||
read -rs "password?Docker registry password: " || return 1
|
password="$(cat)"
|
||||||
echo
|
|
||||||
else
|
else
|
||||||
echo "docker-config-json: password not provided and input is not interactive" >&2
|
read -rs "password?Docker registry password: " || return 1
|
||||||
return 1
|
echo >&2
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user