Debian Codegraph @

ansible_collections/community/sops/tests/integration/targets/vars_sops/run-test.sh

raw
1 #!/usr/bin/env bash
2 # Copyright (c) Ansible Project
3 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
4 # SPDX-License-Identifier: GPL-3.0-or-later
5
6 set -eux
7
8 if [ "$(command -v sops)" == "" ]; then
9 echo "sops is not installed"
10 exit 1
11 fi
12
13 if [ $# -lt 2 ]; then
14 echo "First parameter must be test name, second parameter the SOPS version!"
15 exit 1
16 fi
17 TEST="$1"
18 SOPS_VERSION="$2"
19
20 if [ -e "${TEST}/min-version" ]; then
21 MIN_VERSION="$(cat "${TEST}/min-version")"
22 if [ "$(echo -e "${SOPS_VERSION}\n${MIN_VERSION}" | sort -V | head -1)" != "${MIN_VERSION}" ]; then
23 exit
24 fi
25 fi
26 if [ -e "${TEST}/max-version" ]; then
27 MAX_VERSION="$(cat "${TEST}/max-version")"
28 if [ "$(echo -e "${SOPS_VERSION}\n${MAX_VERSION}" | sort -V | head -1)" != "${SOPS_VERSION}" ]; then
29 exit
30 fi
31 fi
32
33 shift 2
34
35 (
36 cd "${TEST}"
37 if [ -x "setup.sh" ]; then
38 ./setup.sh
39 fi
40 if [ -x "run.sh" ]; then
41 ANSIBLE_VARS_ENABLED=host_group_vars,community.sops.sops ./run.sh "$@" 2>&1 | tee out
42 RESULT=${PIPESTATUS[0]}
43 else
44 ANSIBLE_VARS_ENABLED=host_group_vars,community.sops.sops ansible-playbook playbook.yml -i hosts -v "$@" 2>&1 | tee out
45 RESULT=${PIPESTATUS[0]}
46 fi
47 ./validate.sh "${RESULT}" out
48 )