-
Notifications
You must be signed in to change notification settings - Fork 6
/
concourse-generate-all-pipelines.sh
executable file
·87 lines (77 loc) · 2.76 KB
/
concourse-generate-all-pipelines.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
85
86
87
#!/usr/bin/env bash
set -e
SECRETS=${SECRETS:-../int-secrets}
TEMPLATES=${TEMPLATES:-../paas-templates}
DYNAMIC_DEPLS_FILE_LIST=$(cd $SECRETS && find . -maxdepth 1 -type d -name "*-depls" -o -name "shared")
for i in ${DYNAMIC_DEPLS_FILE_LIST};
do
export DYNAMIC_DEPLS_LIST="$DYNAMIC_DEPLS_LIST $(basename $i)"
done
DEPLS_LIST=${DEPLS_LIST:-${DYNAMIC_DEPLS_LIST}}
DEBUG=${DEBUG:=false}
usage(){
echo "$0" 1>&2
echo -e "No parameter supported. Use environment variables:" 1>&2
echo -e "\t DEBUG: [true|false] display generated pipelines. DEFAULT: false " 1>&2
echo -e "\t DEPLS_LIST: deployments to process. DEFAULT: [$DYNAMIC_DEPLS_LIST] " 1>&2
echo -e "\t IAAS_TYPE: iaas to target. NO DEFAULT VALUE" 1>&2
echo -e "\t OUTPUT_DIR: pipeline generation directory. DEFAULT: [./bootstrap-generated] " 1>&2
echo -e "\t PIPELINE_TYPES: only generate this pipeline. DEFAULT: ALL_PIPELINES " 1>&2
echo -e "\t PROFILES: profiles to apply. NO DEFAULT VALUE" 1>&2
echo -e "\t SECRETS: path to secrets directory. DEFAULT: $SECRETS " 1>&2
echo -e "\t TEMPLATES: path to paas-templates directory. DEFAULT: $TEMPLATES " 1>&2
exit 1
}
if [ $# -ne 0 ]
then
usage
fi
CURRENT_SCRIPT_DIR=$(realpath $0|xargs dirname)
if [ "$SCRIPT_DIR" == "." ]
then
SCRIPT_DIR=..
fi
ROOT_DIR=${CURRENT_SCRIPT_DIR%scripts}
DEBUG_OPTIONS="--no-dump"
if [ "${DEBUG}" = "true" ]
then
echo "INFO: Enabling debug options: dump pipelines"
DEBUG_OPTIONS="--dump"
else
echo "INFO: debug mode disabled"
fi
set +e
SECRET_DIR=$(readlink -e ${SECRETS})
set -e
if [ "$SECRET_DIR" == "" ]
then
echo "SECRETS ($SECRETS) does not exist" 1>&2
usage
exit 1
fi
if [ -z "${OUTPUT_DIR}" ]
then
OUTPUT_DIR=$(readlink -f ${ROOT_DIR}/bootstrap-generated)
fi
mkdir -p ${OUTPUT_DIR}/pipelines
if [ -n "${PIPELINE_TYPES}" ]
then
echo "Only generating pipelines matching ${PIPELINE_TYPES}"
PIPELINES_RESTRICTION="--input ${PIPELINE_TYPES}"
else
echo "No PIPELINE_TYPES detected"
fi
if [ "$PROFILES_AUTOSORT" = "false" ]; then
echo "Disabling profiles auto sort"
PROFILES_AUTOSORT_OPTION="--no-profiles-auto-sort"
else
echo "Enabling profiles auto sort"
PROFILES_AUTOSORT_OPTION="--profiles-auto-sort"
fi
echo "Generating pipelines using secrets in $SECRET_DIR to ${OUTPUT_DIR}/pipelines for ${IAAS_TYPE} (Iaas Type), with profiles: [${PROFILES}]"
for depls in ${DEPLS_LIST};do
"${CURRENT_SCRIPT_DIR}/generate-depls.rb" -d "${depls}" -p "${SECRET_DIR}" -o "${OUTPUT_DIR}" -t "${TEMPLATES}" ${DEBUG_OPTIONS} --iaas "${IAAS_TYPE}" ${PROFILES_AUTOSORT_OPTION} --profiles "${PROFILES}" --no-dump ${PIPELINES_RESTRICTION}
PIPELINE="${depls}-${PIPELINE_TYPES}-generated"
echo "${PIPELINE} generated to ${OUTPUT_DIR}/pipelines"
done
echo "Pipelines generated for: $DEPLS_LIST"