Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions ansible/rebuild_module.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,37 @@
#!/usr/bin/env bash

# Directory in which this script resides
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

TEMPLATE_FILE="$DIR/roles/openshift_client_python/library/openshift_client_python.template.py"
OUTPUT_FILE="$DIR/roles/openshift_client_python/library/openshift_client_python.py"
ANSIBLE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

TEMPLATE_FILE="$ANSIBLE_DIR/roles/openshift_client_python/library/openshift_client_python.template.py"

if [[ -v 1 ]]
then
echo "Running in container mode"
TEMP_DIR="$1"
OUTPUT_FILE="$TEMP_DIR/openshift_client_python.py"
DIGEST_FILE="$TEMP_DIR/rebuild_module.digest"
else
OUTPUT_FILE="$ANSIBLE_DIR/roles/openshift_client_python/library/openshift_client_python.py"
DIGEST_FILE="$ANSIBLE_DIR/rebuild_module.digest"
fi

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

PACKAGES_DIR="$DIR/../packages"
PACKAGES_DIR="$ANSIBLE_DIR/../packages"
if [[ ! -d "$PACKAGES_DIR" ]]; then
echo "Unable to find packages directory: $PACKAGES_DIR"
exit 1
fi

pushd "$PACKAGES_DIR"

# Update module digest so that pr.groovy can ensure it is run after each module change
cat $(find openshift/ -name '*.py' | sort) | md5sum > $DIR/rebuild_module.digest
cat $(find openshift/ -name '*.py' | sort) | md5sum > $DIGEST_FILE
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)

popd

echo "#!/usr/bin/env python" > $OUTPUT_FILE
Expand All @@ -45,4 +56,4 @@ done < "$TEMPLATE_FILE"
if [[ "$replaced" != "1" ]]; then
echo "Unable to find replacement pattern in template"
exit 1
fi
fi
13 changes: 11 additions & 2 deletions hack/verify-ansible-module.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,17 @@ echo -e "Artifacts will be written to: ${OUTPUT_DIR}"
BASE_DIR="$( readlink -e $( dirname "${BASH_SOURCE[0]}" )/..)"

echo -e "\nVerifying ansible module"

cd ${BASE_DIR}/ansible
./rebuild_module.sh
git diff --exit-code rebuild_module.digest || (echo 'You need to run ansible/rebuild_module.sh and include changes in this PR' && exit 1)

if [[ -v RUNTIME_ENV ]]
then
./rebuild_module.sh $OUTPUT_DIR
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)
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)
else
./rebuild_module.sh
git diff --exit-code rebuild_module.digest || (echo 'You need to run ansible/rebuild_module.sh and include changes in this PR' && exit 1)
fi

exit 0