check_docker_registry_secret.sh: update
This commit is contained in:
parent
89cd353690
commit
805b4069ee
@ -7,15 +7,27 @@ check_not_empty() {
|
||||
fi
|
||||
}
|
||||
|
||||
function run()
|
||||
{
|
||||
|
||||
# 检查参数是否为空
|
||||
function run() {
|
||||
check_not_empty "$1" "cluster" && local cluster=$1
|
||||
check_not_empty "$2" "namespace" && local namespace=$2
|
||||
check_not_empty "$3" "secret" && local secret=$3
|
||||
|
||||
kubectl config set-context --current --namespace $namespace
|
||||
echo $cluster $namespace $secret
|
||||
|
||||
for secret in $(kubectl get secrets -n $namespace -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' | grep '\.dockerconfigjson$'); do
|
||||
echo "$cluster $namespace $secret"
|
||||
done
|
||||
}
|
||||
|
||||
function print_base64_data() {
|
||||
local namespace=$1
|
||||
local secret=$2
|
||||
local cluster=$3
|
||||
echo "$cluster $namespace $secret"
|
||||
kubectl get secret $secret -n $namespace --output="jsonpath={.data.\.dockerconfigjson}" | base64 --decode || true
|
||||
}
|
||||
|
||||
cluster="$1"
|
||||
namespace="$2"
|
||||
|
||||
run "$cluster" "$namespace"
|
||||
print_base64_data "$namespace" "$secret" "$cluster"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user