-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path006-admin-access-export.sh
More file actions
executable file
·31 lines (24 loc) · 1.14 KB
/
006-admin-access-export.sh
File metadata and controls
executable file
·31 lines (24 loc) · 1.14 KB
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
#!/bin/bash
# Resource: Access (Under Administration)
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
DATA_DIR="$SCRIPT_DIR"/data/credential-access
if [ -d $DATA_DIR ]; then
rm -rf $DATA_DIR/*
fi
mkdir -p $DATA_DIR
source "$SCRIPT_DIR"/utils/saas-api-call.sh
echo "************************************************************************"
echo "* Exporting Admin Access from TMC SaaS ..."
echo "************************************************************************"
# No longer to support AZURE_AKS and AWS_EKS
credentialList=`tanzu tmc account credential list -o yaml | \
yq eval -o=json - | jq '.' | \
jq 'del(.totalCount)' | \
jq '.credentials |=map(select(.spec.meta.provider != "AZURE_AKS" and .spec.meta.provider != "AWS_EKS"))' | \
jq -c '.credentials[]'`
while IFS= read -r credential; do
name=$(echo "$credential" | jq -r '.fullName.name // ""')
curl_api_call -X GET "v1alpha1/account/credentials:iam/${name}" |jq '.' | yq eval -P - > $DATA_DIR/access---${name}.yaml
done <<< "$credentialList"
relative_path="${DATA_DIR#*migration-scripts/}"
echo "Exported Admin Access from TMC SaaS: $relative_path/*.yaml"