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 <dmihai@microsoft.com>
This commit is contained in:
Dan Mihai 2025-03-19 00:09:32 +00:00
parent b895e3b3e5
commit 59a70a2b28

View File

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