-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path034-base-clustergroups-import.sh
More file actions
executable file
·34 lines (28 loc) · 1.11 KB
/
034-base-clustergroups-import.sh
File metadata and controls
executable file
·34 lines (28 loc) · 1.11 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
32
33
34
#!/bin/bash
# Resource: Cluster group
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
DATA_DIR="$SCRIPT_DIR"/data/clustergroup
if [ ! -d $DATA_DIR ]; then
echo "Nothing to do without directory $DATA_DIR, please backup data first"
exit 0
fi
echo "************************************************************************"
echo "* Importing Cluster Groups into TMC SM ..."
echo "************************************************************************"
clusterGroupList=`cat $DATA_DIR/clustergroups.yaml | yq eval -o=json - | jq '.' | \
jq -c '.clusterGroups[]'`
while IFS= read -r clusterGroup; do
if [[ -z "$clusterGroup" ]]; then
echo "No any clustergroup found"
fi
if [[ -n "$clusterGroup" ]]; then
name=$(echo "$clusterGroup" | jq -r ".fullName.name")
if [[ "$name" != "default" ]]; then
echo "Create clustergroup: $name"
echo "$clusterGroup" | \
jq -r 'del(.fullName.orgId, .meta.annotations, .meta.parentReferences)' | \
tanzu tmc clustergroup create --file -
fi
fi
done <<< "$clusterGroupList"
echo "Imported Cluster Groups into TMC SM ..."