Skip to content

Commit 58d892c

Browse files
committed
More work on the import script
1 parent df5800a commit 58d892c

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

.github/update-templates.sh

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,20 @@
22

33
set -euo pipefail
44

5+
# shellcheck disable=SC2153
56
main() {
67
local wiremock_cloud_url="$WIREMOCK_CLOUD_URL"
78
local wiremock_cloud_username="$WIREMOCK_CLOUD_USERNAME"
89
local wiremock_cloud_api_token="$WIREMOCK_CLOUD_API_TOKEN"
910

11+
updateAll "$wiremock_cloud_url" "$wiremock_cloud_username" "$wiremock_cloud_api_token"
12+
}
13+
14+
updateAll() {
15+
local wiremock_cloud_url=$1
16+
local wiremock_cloud_username=$2
17+
local wiremock_cloud_api_token=$3
18+
1019
for dir in ../*; do
1120
if [[ -d "$dir" ]]; then
1221
update "${dir#../}" "$wiremock_cloud_url" "$wiremock_cloud_username" "$wiremock_cloud_api_token"
@@ -27,22 +36,25 @@ update() {
2736

2837
local data; data="$(jq "{apiTemplate: { slug: .slug, name: .title, description: .description, tags: .tags, logoData: \"$logoData\"}, logoMediaType: .logoMediaType }" < "$metadata")"
2938

30-
echo "SENDING $data"
39+
echo "Creating template: $dir via POST to $wiremock_cloud_url/v1/api-templates/public"
3140

32-
local apiTemplate; apiTemplate="$(curl -v \
33-
-u "$wiremock_cloud_username:$wiremock_cloud_api_token" \
34-
-H 'Content-Type: application/json' \
35-
-d "$data" \
36-
"$wiremock_cloud_url/v1/api-templates/public")"
41+
local apiTemplate; apiTemplate="$( \
42+
curl -fsS \
43+
-u "$wiremock_cloud_username:$wiremock_cloud_api_token" \
44+
-H 'Content-Type: application/json' \
45+
-d "$data" \
46+
"$wiremock_cloud_url/v1/api-templates/public" \
47+
)"
3748

38-
echo "GOT apiTemplate $apiTemplate"
49+
echo "Created apiTemplate $apiTemplate"
3950

4051
local apiTemplateId; apiTemplateId="$(echo "$apiTemplate" | jq -r .apiTemplate.id)"
41-
echo "GOT apiTemplateId $apiTemplateId"
4252

4353
local stubsFile; stubsFile=$(jq -r '.stubs' < "$metadata")
4454

45-
curl -v \
55+
echo "Setting stubs: $stubsFile for template $dir via PUT to $wiremock_cloud_url/v1/api-templates/$apiTemplateId/stubs"
56+
57+
curl -fsS \
4658
-u "$wiremock_cloud_username:$wiremock_cloud_api_token" \
4759
-H 'Content-Type: application/json' \
4860
-X PUT \

0 commit comments

Comments
 (0)