Skip to content

Commit

Permalink
Avoid using $? directly in the if statement.
Browse files Browse the repository at this point in the history
Fix ShellCheck SC2181 error

Ref: https://www.shellcheck.net/wiki/SC2181

Signed-off-by: Pradipta Banerjee <pradipta.banerjee@gmail.com>
  • Loading branch information
bpradipt committed Jul 27, 2024
1 parent a2c8974 commit 550f10a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion config/peerpods/podvm/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,8 @@ function prepare_source_code() {
if [[ "${AGENT_POLICY}" ]]; then
echo "Custom agent policy is being set through the AGENT_POLICY value"
echo "${AGENT_POLICY}" | base64 -d >"${podvm_dir}"/files/etc/kata-opa/custom.rego
if [[ $? == 0 ]] && grep -q "agent_policy" "${podvm_dir}"/files/etc/kata-opa/custom.rego; then # checks policy validity
return_code=$?
if [[ "$return_code" == 0 ]] && grep -q "agent_policy" "${podvm_dir}"/files/etc/kata-opa/custom.rego; then # checks policy validity
ln -sf custom.rego "${podvm_dir}"/files/etc/kata-opa/default-policy.rego
else
error_exit "Invalid AGENT_POLICY value set, expected base64 encoded valid agent policy, got: \"${AGENT_POLICY}\""
Expand Down

0 comments on commit 550f10a

Please sign in to comment.