Add file type check to upload-swift-artifacts
deploy-artifacts supports only 'RPM' and 'gzip compressed data' [1] while upload-swift-artifacts will allow the uploading of any file. deploy-artifacts will fail if an unsupported file type is downloaded resutling in a stack deploy failure. This update add a check_file function which will validate the file type of each file before it is uploaded. The script will exit with a failure if an unsupported file is attempted. Change-Id: I8c46110fa2779b818bc5b7882788f5d8739c1d2a 1: https://github.com/openstack/tripleo-heat-templates/blob/master/puppet/deploy-artifacts.sh#L12-L23
This commit is contained in:
parent
2f42cbe2a1
commit
86cce51067
@ -43,6 +43,35 @@ function show_options {
|
|||||||
exit $1
|
exit $1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function check_file
|
||||||
|
{
|
||||||
|
local FILE=$1
|
||||||
|
supported_files=(" RPM " "gzip compressed data")
|
||||||
|
array_length=${#supported_files[@]}
|
||||||
|
|
||||||
|
local test_type=`file $FILE`
|
||||||
|
|
||||||
|
local i=0
|
||||||
|
local matched=0
|
||||||
|
|
||||||
|
while [ $i -ne $array_length -a $matched -eq 0 ]
|
||||||
|
do
|
||||||
|
if [[ "$test_type" =~ ${supported_files[$i]} ]]
|
||||||
|
then
|
||||||
|
matched=1
|
||||||
|
fi
|
||||||
|
i=$((i+1))
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ $matched -eq 0 ]
|
||||||
|
then
|
||||||
|
echo "Not a supported file type: $FILE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
TEMP=`getopt -o he:f:c:s: -l help,environment:,file:,container:,seconds: -n $SCRIPT_NAME -- "$@"`
|
TEMP=`getopt -o he:f:c:s: -l help,environment:,file:,container:,seconds: -n $SCRIPT_NAME -- "$@"`
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
echo "Terminating..." >&2
|
echo "Terminating..." >&2
|
||||||
@ -144,5 +173,6 @@ function upload_file {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for FILE in ${FILES[@]}; do
|
for FILE in ${FILES[@]}; do
|
||||||
|
check_file "$FILE"
|
||||||
upload_file "$FILE"
|
upload_file "$FILE"
|
||||||
done
|
done
|
||||||
|
Loading…
x
Reference in New Issue
Block a user