-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathcfn-test-create-inputs.sh
executable file
·50 lines (40 loc) · 1.49 KB
/
cfn-test-create-inputs.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
#!/usr/bin/env bash
# cfn-test-create-inputs.sh
#
# This tool generates json files in the inputs/ for `cfn test`.
#
set -o errexit
set -o nounset
set -o pipefail
function usage {
echo "usage:$0 <project_name>"
}
if [ "$#" -ne 1 ]; then usage; fi
if [[ "$*" == help ]]; then usage; fi
rm -rf inputs
mkdir inputs
#project_id
projectName="${1}"
bindPassword="$LDAP_BIND_PASSWORD"
bindUsername="$LDAP_BIND_USER_NAME"
hostname="$LDAP_HOST_NAME"
projectId=$(atlas projects list --output json | jq --arg NAME "${projectName}" -r '.results[] | select(.name==$NAME) | .id')
if [ -z "$projectId" ]; then
projectId=$(atlas projects create "${projectName}" --output=json | jq -r '.id')
echo -e "Created project \"${projectName}\" with id: ${projectId}\n"
else
echo -e "FOUND project \"${projectName}\" with id: ${projectId}\n"
fi
jq --arg project_id "$projectId" \
--arg bindPassword "$bindPassword" \
--arg bindUsername "$bindUsername" \
--arg hostname "$hostname" \
'.ProjectId?|=$project_id | .BindPassword?|=$bindPassword | .BindUsername?|=$bindUsername | .Hostname?|=$hostname' \
"$(dirname "$0")/inputs_1_create.template.json" >"inputs/inputs_1_create.json"
jq --arg project_id "$projectId" \
--arg bindPassword "$bindPassword" \
--arg bindUsername "$bindUsername" \
--arg hostname "$hostname" \
'.ProjectId?|=$project_id | .BindPassword?|=$bindPassword | .BindUsername?|=$bindUsername | .Hostname?|=$hostname' \
"$(dirname "$0")/inputs_1_update.template.json" >"inputs/inputs_1_update.json"
ls -l inputs