tripleo-common/scripts/upload-puppet-modules
Purandhar Sairam Mannidi 60a2c347f2 Remove unused input parameters for upload-artifacts
Currently, we pass parameters for expiring the artifacts for the
deployment but we don't use them in swiftless architecture. Also other
parameters like BIND_PORT and BIND_ADDRESS.

This patch removes all the unused parameters in upload-artifacts.

Change-Id: If04de938d14c30d8aedf3157bcbc0a8845c5d532
Signed-off-by: Purandhar Sairam Mannidi <pmannidi@redhat.com>
2021-09-10 18:23:28 +10:00

89 lines
2.9 KiB
Bash
Executable File

#!/bin/bash
# Copyright 2016 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# Script to upload directory tarball of puppet modules to a artifact container.
#
set -eu
set -o pipefail
SCRIPT_NAME=$(basename $0)
SCRIPT_HOME=$(cd $(dirname $0); pwd)
PUPPET_MODULES_TMP=''
function clean {
[ -z "${PUPPET_MODULES_TMP}" ] || rm -rf ${PUPPET_MODULES_TMP}
}
trap clean SIGINT SIGTERM EXIT
function show_options {
echo "Usage: $SCRIPT_NAME <directory>"
echo
echo "Options:"
echo " -h, --help -- print this help."
echo " -d <directory> -- Puppet modules directory. Required."
echo " -c <container> -- Artifact container to use."
echo " Default: overcloud-artifacts"
echo " --environment <env> -- Generate this heat <env>"
echo " Default: $HOME/.tripleo/environments/puppet-modules-url.yaml"
echo
echo "Upload a directory tarball of puppet modules to a artifact container"
echo "and generate a heat environment file containing the required"
echo "DeployArtifactURLs parameter so that it is used for TripleO deployment."
echo
exit $1
}
TEMP=`getopt -o h:ed:c: -l help,environment:,directory:,container: -n $SCRIPT_NAME -- "$@"`
if [ $? != 0 ]; then
echo "Terminating..." >&2
exit 1
fi
# Note the quotes around `$TEMP': they are essential!
eval set -- "$TEMP"
ENVIRONMENT_FILE="$HOME/.tripleo/environments/puppet-modules-url.yaml"
MODULES_DIRECTORY=
CONTAINER_NAME=overcloud-artifacts
while true ; do
case "$1" in
-h|--help) show_options 0 >&2;;
-e|--environment) ENVIRONMENT_FILE=$2 ; shift 2;;
-d|--directory) MODULES_DIRECTORY=$2 ; shift 2;;
-c|--container) CONTAINER_NAME=$2 ; shift 2;;
--) shift ; break;;
*) echo "Error: unsupported option $1." ; exit 1;;
esac
done
: ${MODULES_DIRECTORY:?--directory is required}
modules_directory=${MODULES_DIRECTORY%/}
modules_directory=${modules_directory#/}
: ${CONTAINER_NAME:?No artifact --container was specified}
echo "Creating tarball..."
PUPPET_MODULES_TMP=$(mktemp -d -t 'puppet-modules-XXXXXXX')
tar --transform "s|${modules_directory}|etc/puppet/modules|" \
-czf "$PUPPET_MODULES_TMP/puppet-modules.tar.gz" $MODULES_DIRECTORY
echo "Tarball created."
upload-artifacts -f "$PUPPET_MODULES_TMP/puppet-modules.tar.gz" \
-c "$CONTAINER_NAME" \
--environment "$ENVIRONMENT_FILE"