-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsync-templates.sh
More file actions
executable file
·22 lines (18 loc) · 917 Bytes
/
Copy pathsync-templates.sh
File metadata and controls
executable file
·22 lines (18 loc) · 917 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/bash
set -e
NEXT_TOKEN=""
rm -f list-templates.json
while
aliyun oos ListTemplates --ShareType Public --MaxResults 100 --NextToken $NEXT_TOKEN > list-templates-next-token.json
NEXT_TOKEN=`cat list-templates-next-token.json | jq -r '.NextToken'`
NEW_TEMPALTES=`cat list-templates-next-token.json | jq 'with_entries(select([.key] | inside(["Templates"])))'`
if [ -f list-templates.json ]; then
ORIGIN_TEMPLATES=`cat list-templates.json`
echo $ORIGIN_TEMPLATES $NEW_TEMPALTES | jq -s '.[0].Templates=([.[].Templates]|flatten)|.[0]' > list-templates.json
else
echo $NEW_TEMPALTES > list-templates.json
fi
[ "$NEXT_TOKEN" != "null" ]
do :; done
cat list-templates.json | jq -cr '.Templates[].TemplateName' | xargs -n1 sh -c 'sleep 1 && aliyun oos GetTemplate --TemplateName $1 | jq -r ".Content" > "templates/$1.yaml"' sh
rm -f list-templates-next-token.json