From b9c969be56f125d279694fa53a60516b219cbff8 Mon Sep 17 00:00:00 2001 From: Nikolai Kondrashov Date: Fri, 19 Jan 2024 15:26:38 +0200 Subject: [PATCH] cloud: Add password_is_updated() --- kcidb/cloud/password.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/kcidb/cloud/password.sh b/kcidb/cloud/password.sh index 0daa2eb6..2f66b10e 100644 --- a/kcidb/cloud/password.sh +++ b/kcidb/cloud/password.sh @@ -226,6 +226,32 @@ function password_is_specified() { return 0 } +# Check if any of the passwords with specified names are (going to be) updated +# (specified on the command line, or missing). +# Args: name... +# Output: "true" if all secrets exists, "false" otherwise. +function password_is_updated() { + declare name + declare secret_exists + assert password_exists "$@" + while (($#)); do + name="$1"; shift + if password_is_specified "$name"; then + echo true + return + fi + if password_secret_is_specified "$name"; then + secret_exists="$(password_secret_exists "$name")" + if "$secret_exists"; then + continue + fi + fi + echo true + return + done + echo false +} + # Deploy passwords to their secrets (assuming they're set with # "password_secret_set"). For every password deploy only if the password is # specified, or the secret doesn't exist.