From 6e318910c09869e054b11b7ee50a245205526dd4 Mon Sep 17 00:00:00 2001 From: Pavel Tankov <4014969+ptankov@users.noreply.github.com> Date: Mon, 2 Oct 2023 16:40:48 +0300 Subject: [PATCH 1/2] converting variables in a function to local --- e2e-tests/functions | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/e2e-tests/functions b/e2e-tests/functions index ef4c97b865..c87c68c5bd 100644 --- a/e2e-tests/functions +++ b/e2e-tests/functions @@ -422,6 +422,9 @@ get_pod_by_role() { } check_passwords_leak() { + local secrets + local passwords + local pods secrets=$(kubectl -n "${NAMESPACE}" get secrets -o json | jq -r '.items[] | select(.data."password"? != null) | .data."password"' ; kubectl -n "${NAMESPACE}" get secrets -o json | jq -r '.items[] | select(.data."pgbouncer-password"? != null) | .data."pgbouncer-password"') @@ -429,6 +432,9 @@ check_passwords_leak() { pods=$(kubectl -n "${NAMESPACE}" get pods -o name | awk -F "/" '{print $2}') collect_logs() { + local containers + local count + NS=$1 for p in $pods; do containers=$(kubectl -n "$NS" get pod $p -o jsonpath='{.spec.containers[*].name}') From b8964212852679c71198bd88054785e174ddfe98 Mon Sep 17 00:00:00 2001 From: Pavel Tankov <4014969+ptankov@users.noreply.github.com> Date: Wed, 11 Oct 2023 15:38:58 +0300 Subject: [PATCH 2/2] improving readability --- e2e-tests/functions | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/e2e-tests/functions b/e2e-tests/functions index c87c68c5bd..b1035cba88 100644 --- a/e2e-tests/functions +++ b/e2e-tests/functions @@ -426,7 +426,10 @@ check_passwords_leak() { local passwords local pods - secrets=$(kubectl -n "${NAMESPACE}" get secrets -o json | jq -r '.items[] | select(.data."password"? != null) | .data."password"' ; kubectl -n "${NAMESPACE}" get secrets -o json | jq -r '.items[] | select(.data."pgbouncer-password"? != null) | .data."pgbouncer-password"') + secrets=$( + kubectl -n "${NAMESPACE}" get secrets -o json | jq -r '.items[] | select(.data."password"? != null) | .data."password"' + kubectl -n "${NAMESPACE}" get secrets -o json | jq -r '.items[] | select(.data."pgbouncer-password"? != null) | .data."pgbouncer-password"' + ) passwords="$(for i in $secrets; do base64 -d <<< $i; echo; done) $secrets" pods=$(kubectl -n "${NAMESPACE}" get pods -o name | awk -F "/" '{print $2}')