Skip to content

Commit 960684b

Browse files
Merge pull request #126 from bradmwilliams/container-scripts-fix
Adding support for running scripts in containers
2 parents d1aaf53 + 73459ee commit 960684b

File tree

2 files changed

+30
-10
lines changed

2 files changed

+30
-10
lines changed

ansible/rebuild_module.sh

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,37 @@
11
#!/usr/bin/env bash
22

33
# Directory in which this script resides
4-
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
5-
6-
TEMPLATE_FILE="$DIR/roles/openshift_client_python/library/openshift_client_python.template.py"
7-
OUTPUT_FILE="$DIR/roles/openshift_client_python/library/openshift_client_python.py"
4+
ANSIBLE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
5+
6+
TEMPLATE_FILE="$ANSIBLE_DIR/roles/openshift_client_python/library/openshift_client_python.template.py"
7+
8+
if [[ -v 1 ]]
9+
then
10+
echo "Running in container mode"
11+
TEMP_DIR="$1"
12+
OUTPUT_FILE="$TEMP_DIR/openshift_client_python.py"
13+
DIGEST_FILE="$TEMP_DIR/rebuild_module.digest"
14+
else
15+
OUTPUT_FILE="$ANSIBLE_DIR/roles/openshift_client_python/library/openshift_client_python.py"
16+
DIGEST_FILE="$ANSIBLE_DIR/rebuild_module.digest"
17+
fi
818

919
if [[ ! -f "$TEMPLATE_FILE" ]]; then
1020
echo "Unable to find template file: $TEMPLATE_FILE"
1121
exit 1
1222
fi
1323

14-
PACKAGES_DIR="$DIR/../packages"
24+
PACKAGES_DIR="$ANSIBLE_DIR/../packages"
1525
if [[ ! -d "$PACKAGES_DIR" ]]; then
1626
echo "Unable to find packages directory: $PACKAGES_DIR"
1727
exit 1
1828
fi
19-
2029
pushd "$PACKAGES_DIR"
30+
2131
# Update module digest so that pr.groovy can ensure it is run after each module change
22-
cat $(find openshift/ -name '*.py' | sort) | md5sum > $DIR/rebuild_module.digest
32+
cat $(find openshift/ -name '*.py' | sort) | md5sum > $DIGEST_FILE
2333
ENCODED_TGZ=$(tar c --owner=0 --numeric-owner --group=0 --mtime='UTC 2019-01-01' $(find openshift/ -name '*.py' | sort) | gzip -c -n | base64 --wrap=0)
34+
2435
popd
2536

2637
echo "#!/usr/bin/env python" > $OUTPUT_FILE
@@ -45,4 +56,4 @@ done < "$TEMPLATE_FILE"
4556
if [[ "$replaced" != "1" ]]; then
4657
echo "Unable to find replacement pattern in template"
4758
exit 1
48-
fi
59+
fi

hack/verify-ansible-module.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,17 @@ echo -e "Artifacts will be written to: ${OUTPUT_DIR}"
1111
BASE_DIR="$( readlink -e $( dirname "${BASH_SOURCE[0]}" )/..)"
1212

1313
echo -e "\nVerifying ansible module"
14+
1415
cd ${BASE_DIR}/ansible
15-
./rebuild_module.sh
16-
git diff --exit-code rebuild_module.digest || (echo 'You need to run ansible/rebuild_module.sh and include changes in this PR' && exit 1)
16+
17+
if [[ -v RUNTIME_ENV ]]
18+
then
19+
./rebuild_module.sh $OUTPUT_DIR
20+
diff --brief $BASE_DIR/ansible/rebuild_module.digest $OUTPUT_DIR/rebuild_module.digest || (echo 'You need to run ansible/rebuild_module.sh and include changes in this PR' && exit 1)
21+
diff --brief $BASE_DIR/ansible/roles/openshift_client_python/library/openshift_client_python.py $OUTPUT_DIR/openshift_client_python.py || (echo 'You need to run ansible/rebuild_module.sh and include changes in this PR' && exit 1)
22+
else
23+
./rebuild_module.sh
24+
git diff --exit-code rebuild_module.digest || (echo 'You need to run ansible/rebuild_module.sh and include changes in this PR' && exit 1)
25+
fi
1726

1827
exit 0

0 commit comments

Comments
 (0)