fix(zsh/kubernetes): improve password handling in docker-config-json function

This commit is contained in:
Jim Myhrberg
2025-11-20 13:58:53 +00:00
parent e60b35ecb4
commit 7248d531b8

View File

@@ -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