kata-containers/tests/install_opa.sh
Paul Meyer 71796f7b12 ci/static-checks: install opa
Make open-policy-agent available for static checks as prerequisite for rego checks.

Signed-off-by: Paul Meyer <katexochen0@gmail.com>
2025-06-12 10:46:43 +02:00

41 lines
1.0 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# Copyright (c) Edgeless Systems GmbH
#
# SPDX-License-Identifier: Apache-2.0
set -eou pipefail
[[ -n "${DEBUG:-}" ]] && set -o xtrace
test_dir=$(realpath "$(dirname "${BASH_SOURCE[0]}")")
source "${test_dir}/common.bash"
install_opa()
{
local url
local version
url=$(get_test_version "externals.opa.url")
version=$(get_test_version "externals.opa.version")
if opa version 2>/dev/null | grep -q "${version}"; then
info "OPA version ${version} is already installed"
return 0
fi
info "Installing OPA version ${version} from ${url}"
curl -fsSL "${url}/releases/download/${version}/opa_linux_amd64_static" \
-o "/usr/local/bin/opa" \
|| die "Failed to download OPA binary"
chmod +x "/usr/local/bin/opa" \
|| die "Failed to make OPA binary executable"
command -v opa &>/dev/null \
|| die "OPA binary not found in PATH after installation"
info "Successfully installed OPA version ${version}"
}
install_opa