From 59a70a2b28757dabb2ad2dfe3379a00364a520d3 Mon Sep 17 00:00:00 2001 From: Dan Mihai Date: Wed, 19 Mar 2025 00:09:32 +0000 Subject: [PATCH] tests: k8s/tests_common: avoid masking return values Avoid masking command return values by declaring and only then assigning. ShellCheck: warning: Declare and assign separately to avoid masking return values. [SC2155] Signed-off-by: Dan Mihai --- tests/integration/kubernetes/tests_common.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/integration/kubernetes/tests_common.sh b/tests/integration/kubernetes/tests_common.sh index 9ab9b3b1f7..e30972a786 100644 --- a/tests/integration/kubernetes/tests_common.sh +++ b/tests/integration/kubernetes/tests_common.sh @@ -220,7 +220,8 @@ add_exec_to_policy_settings() { shift # Create a JSON array of strings containing all the args of the command to be allowed. - local exec_args=$(printf "%s\n" "$@" | jq -R | jq -sc) + local exec_args + exec_args=$(printf "%s\n" "$@" | jq -R | jq -sc) # Change genpolicy settings to allow kubectl to exec the command specified by the caller. local jq_command=".request_defaults.ExecProcessRequest.allowed_commands |= . + [${exec_args}]" @@ -289,7 +290,8 @@ add_allow_all_policy_to_yaml() { # Previous version of yq was not ready to handle multiple objects in a single yaml. # By default was changing only the first object. # With yq>4 we need to make it explicit during the read and write. - local resource_kind=$(yq .kind "${yaml_file}" | head -1) + local resource_kind + resource_kind=$(yq .kind "${yaml_file}" | head -1) case "${resource_kind}" in