-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathdesign-config.sh
executable file
·130 lines (105 loc) · 3.72 KB
/
design-config.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/usr/bin/env bash
echo "Enter foundation name [toolsmiths-pas]: "
read FOUNDATION
echo "Enter Pivnet product slug [p-rabbitmq]: "
read SLUG
#echo "Enter tile config temp dir [~/workspace/platform-automation]: "
#read CONFIG_HOME
echo "Enter secrets home dir [~/workspace/platform-automation-private]: "
read SECRETS_HOME
# Set inputs or defaults
FOUNDATION=${FOUNDATION:-toolsmiths-pas}
SLUG=${SLUG:-p-rabbitmq}
#CONFIG_HOME=${CONFIG_HOME:-~/workspace/platform-automation}
SECRETS_HOME=${SECRETS_HOME:-~/workspace/platform-automation-private}
SECRETS_FILE_COMMON=${SECRETS_HOME}/${FOUNDATION}/common.yml
SECRETS_FILE=${SECRETS_HOME}/${FOUNDATION}/${SLUG}.yml
#TEMP_DIR=${TEMP_DIR:-_tmp}
TEMP_DIR=_tmp
# Confirm
echo "Designing config using:"
echo " secrets files: ${SECRETS_FILE_COMMON}"
echo " ${SECRETS_FILE}"
echo " tmp dir: ${TEMP_DIR}"
echo " Continue? [Y/N]: "
read GO
if [[ $GO != "Y" ]]; then
echo "Aborting fly set-pipeline..."
return -print 2>/dev/null || exit 1
fi
if [[ ! -f ${SECRETS_FILE_COMMON} || ! -f ${SECRETS_FILE} ]]; then
echo "Error: secrets files specified above must exist"
return -print 2>/dev/null || exit 1
fi
PIVNET_API_TOKEN=$(om interpolate \
--config ${SECRETS_FILE_COMMON} \
--path /pivnet_api_token)
BUILD=$(om interpolate \
--config ${SECRETS_FILE} \
--path /product_build)
VERSION=$(om interpolate \
--config ${SECRETS_FILE} \
--path /product_version)
GLOB=$(om interpolate \
--config ${SECRETS_FILE} \
--path /pivnet_file_glob)
CONFIG_TEMPLATE=$(om interpolate \
--config ${SECRETS_FILE_COMMON} \
--path /config_file)
VARS_FILES=$(om interpolate \
--config ${SECRETS_FILE_COMMON} \
--path /vars_files)
OPS_FILES=$(om interpolate \
--config ${SECRETS_FILE} \
--path /ops_files)
# Get tile config template
echo "Getting config template from PivNet"
rm -rf ${TEMP_DIR}
mkdir ${TEMP_DIR}
om config-template \
--output-directory ${TEMP_DIR} \
--pivnet-api-token "${PIVNET_API_TOKEN}" \
--pivnet-product-slug "${SLUG}" \
--product-version "${VERSION}" \
--product-file-glob "${GLOB}"
printf "\nConfig template copied to ${TEMP_DIR}\n\n"
# Parse vars files
vars_files_args=("")
for vf in ${VARS_FILES}
do
vars_files_args+=("--vars-file ${vf}")
done
# Parse options files
if [ "${OPS_FILES}" == "null" ]; then
rm -f ${TEMP_DIR}/vars/empty-file.yml
touch ${TEMP_DIR}/vars/empty-file.yml
OPS_FILES=empty-file.yml
fi
ops_files_args=("")
for of in ${OPS_FILES}
do
ops_files_args+=("--ops-file vars/${of}")
done
printf "\nRunning designer with the following env setup:\n\n"
pushd ${TEMP_DIR} > /dev/null
ln -s ${SLUG}/${BUILD}/ vars
echo "working_dir: ${PWD}"
echo "secrets: ${SECRETS_FILE}"
echo "config: vars/${CONFIG_TEMPLATE}"
echo "vars_files: ${vars_files_args[@]}"
echo "ops_files: ${ops_files_args[@]}"
printf "\nGiven your tile config file, the following parameters need to be defined:\n\n"
om interpolate --config vars/${CONFIG_TEMPLATE} \
${ops_files_args[@]} \
${vars_files_args[@]} \
--vars-file ${SECRETS_FILE} \
> /dev/null
popd > /dev/null
# Generate list of additional variables for which values need to be provided.
printf "\n\n----------\nNext steps:\n"
printf "\n1. Satisfied with your configuration? Copy parameters listed above to your config files\n"
printf " (common and/or tile-specific) and provide values as needed\n\n"
printf "\n2. Otherwise, change the list of \"ops_files\" in your tile config file and re-run this\n"
printf " script until you are satisfied with your configuration\n"
printf " - For a list of ops_files to choose from, see the _tmp directory created by this script"
printf "\n"