mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-23 05:58:04 +00:00
tests: setup: Improve setup script for kubernetes tests
This PR makes general improvements like definition of variables and the use of them to improve the general setup script for kubernetes tests. Signed-off-by: Gabriela Cervantes <gabriela.cervantes.tellez@intel.com>
This commit is contained in:
parent
461b6e7c93
commit
0066aebd84
@ -15,8 +15,16 @@ export KATA_HOST_OS="${KATA_HOST_OS:-}"
|
|||||||
export KATA_HYPERVISOR="${KATA_HYPERVISOR:-}"
|
export KATA_HYPERVISOR="${KATA_HYPERVISOR:-}"
|
||||||
export PULL_TYPE="${PULL_TYPE:-default}"
|
export PULL_TYPE="${PULL_TYPE:-default}"
|
||||||
|
|
||||||
|
declare -r kubernetes_dir=$(dirname "$(readlink -f "$0")")
|
||||||
|
declare -r runtimeclass_workloads_work_dir="${kubernetes_dir}/runtimeclass_workloads_work"
|
||||||
|
declare -r runtimeclass_workloads_dir="${kubernetes_dir}/runtimeclass_workloads"
|
||||||
|
declare -r kata_opa_dir="${kubernetes_dir}/../../../src/kata-opa"
|
||||||
|
source "${kubernetes_dir}/../../common.bash"
|
||||||
|
source "${kubernetes_dir}/tests_common.sh"
|
||||||
|
|
||||||
|
|
||||||
if [ -n "${K8S_TEST_POLICY_FILES:-}" ]; then
|
if [ -n "${K8S_TEST_POLICY_FILES:-}" ]; then
|
||||||
K8S_TEST_POLICY_FILES=($K8S_TEST_POLICY_FILES)
|
K8S_TEST_POLICY_FILES=("${K8S_TEST_POLICY_FILES}")
|
||||||
else
|
else
|
||||||
K8S_TEST_POLICY_FILES=( \
|
K8S_TEST_POLICY_FILES=( \
|
||||||
"allow-all.rego" \
|
"allow-all.rego" \
|
||||||
@ -24,29 +32,22 @@ else
|
|||||||
)
|
)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
declare -r kubernetes_dir=$(dirname "$(readlink -f "$0")")
|
|
||||||
source "${kubernetes_dir}/../../common.bash"
|
|
||||||
source "${kubernetes_dir}/tests_common.sh"
|
|
||||||
|
|
||||||
reset_workloads_work_dir() {
|
reset_workloads_work_dir() {
|
||||||
rm -rf ${kubernetes_dir}/runtimeclass_workloads_work
|
rm -rf "${runtimeclass_workloads_work_dir}"
|
||||||
cp -R ${kubernetes_dir}/runtimeclass_workloads ${kubernetes_dir}/runtimeclass_workloads_work
|
cp -R "${runtimeclass_workloads_dir}" "${runtimeclass_workloads_work_dir}"
|
||||||
setup_policy_files
|
setup_policy_files
|
||||||
}
|
}
|
||||||
|
|
||||||
setup_policy_files() {
|
setup_policy_files() {
|
||||||
declare -r kata_opa_dir="${kubernetes_dir}/../../../src/kata-opa"
|
|
||||||
declare -r workloads_work_dir="${kubernetes_dir}/runtimeclass_workloads_work"
|
|
||||||
|
|
||||||
# Copy hard-coded policy files used for basic policy testing.
|
# Copy hard-coded policy files used for basic policy testing.
|
||||||
for policy_file in ${K8S_TEST_POLICY_FILES[@]}
|
for policy_file in "${K8S_TEST_POLICY_FILES[@]}"
|
||||||
do
|
do
|
||||||
cp "${kata_opa_dir}/${policy_file}" ${kubernetes_dir}/runtimeclass_workloads_work/
|
cp "${kata_opa_dir}/${policy_file}" "${runtimeclass_workloads_work_dir}"
|
||||||
done
|
done
|
||||||
|
|
||||||
# For testing more sophisticated policies, create genpolicy settings that are common for all tests.
|
# For testing more sophisticated policies, create genpolicy settings that are common for all tests.
|
||||||
# Some of the tests will make temporary copies of these common settings and customize them as needed.
|
# Some of the tests will make temporary copies of these common settings and customize them as needed.
|
||||||
create_common_genpolicy_settings "${workloads_work_dir}"
|
create_common_genpolicy_settings "${runtimeclass_workloads_work_dir}"
|
||||||
}
|
}
|
||||||
|
|
||||||
add_annotations_to_yaml() {
|
add_annotations_to_yaml() {
|
||||||
|
Loading…
Reference in New Issue
Block a user