feat(velero): add possibility to specify a tenant list by cli

This commit is contained in:
alegrey91
2021-07-15 16:23:35 +02:00
committed by Dario Tranchitella
parent 6f208a6e0e
commit 502e9a556f

View File

@@ -13,6 +13,7 @@
KUBECFGFILE="$HOME/.kube/config"
KUBEOPTIONS="--kubeconfig=$KUBECFGFILE"
TMPDIR=/tmp
TENANTS=""
# Print usage to stdout.
# Arguments:
@@ -59,9 +60,15 @@ check_prerequisite () {
# Outputs:
# list of the tenants.
get_tenant_list () {
tenants=$(kubectl "$KUBEOPTIONS" get tnt \
--no-headers -o custom-columns=":.metadata.name")
echo $tenants
if [ ! -z "$TENANTS" ]; then
echo "$TENANTS"
return
else
tenants=$(kubectl "$KUBEOPTIONS" get tnt \
--no-headers -o custom-columns=":.metadata.name")
echo $tenants
fi
return
}
# Retrive namespace list.
@@ -93,7 +100,7 @@ cluster_backup () {
while IFS= read -r line; do
apiVersion=$(echo "$line" | awk '{ print $1 }')
tnt=$(echo "$line" | awk '{ print $2 }')
d=$(echo "$line" | awk '{ print $3 }')
uid=$(echo "$line" | awk '{ print $3 }')
cat <<EOF > "$TMPDIR/tenant_$tnt"
{
@@ -169,6 +176,10 @@ while :; do
update_kube_options
shift
;;
-t|--tenant)
TENANTS="${2}"
shift
;;
*)
break
esac