forked from terraform-ibm-modules/terraform-ibm-satellite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake-release-satellite.sh
executable file
·84 lines (73 loc) · 1.84 KB
/
make-release-satellite.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/sh
# make a tgz out of the terraform, modifying the paths to modules beforehand
# --dirname - where to do the worker
# --verison - version for the tgz name
# --cloud - aws, azure, gcp, ibm, or vmware
set -e
while [[ "$#" -gt 0 ]]; do
case $1 in
--dirname) RELEASE_DIR="$2"; shift ;;
--version) RELEASE_VERSION="$2"; shift ;;
--cloud) CLOUD="$2"; shift ;;
*) echo "Unknown parameter passed: $1"; exit 1 ;;
esac
shift
done
if [ -z "$RELEASE_DIR" ]; then
echo "dirname parameter is required"
ERROR=true
fi
if [ -z "$RELEASE_VERSION" ]; then
echo "version parameter is required"
ERROR=true
fi
if [ -z "$CLOUD" ]; then
echo "cloud parameter is required"
ERROR=true
fi
if [ "$ERROR" = true ] ; then
echo "exiting on error"
exit 1
fi
case $CLOUD in
aws)
CATALOG_NAME='satellite-aws'
;;
azure)
CATALOG_NAME='sat-azure'
;;
gcp)
CATALOG_NAME='satellite-gcp'
;;
ibm)
CATALOG_NAME='satellite-ibm'
;;
vmware)
CATALOG_NAME='satellite-vmware'
;;
*)
echo "Unknown cloud type. Cloud choices are aws, azure, gcp, ibm."
exit 1
;;
esac
# remove refs/tags/ to get the version number
if [[ $RELEASE_VERSION == refs/tags/v* ]]; then
RELEASE_VERSION=${RELEASE_VERSION:10}
fi
OUTPUT_DIR=releases/$RELEASE_DIR/$CLOUD/$CATALOG_NAME
TAR_NAME="$CLOUD-$RELEASE_VERSION.tgz"
echo "output directory: $OUTPUT_DIR"
echo "tar name: $TAR_NAME"
echo "catalog name is $CATALOG_NAME"
mkdir -p $OUTPUT_DIR
cp -r examples/satellite-$CLOUD/. $OUTPUT_DIR
if [[ $CLOUD != 'vmware' ]]; then
cp -r modules $OUTPUT_DIR
# note, gnu sed. If on MacOS, use gsed or add '' after -i
sed -i 's#../../modules#./modules#g' $OUTPUT_DIR/*.tf
fi
cd $OUTPUT_DIR/..
# chown should only be needed locally so username isn't in tar
# chown -R nobody s
echo `pwd`
tar -czf ../../$TAR_NAME $CATALOG_NAME