From 502e9a556f40b5fd925f3bc32b0f56d767406256 Mon Sep 17 00:00:00 2001 From: alegrey91 Date: Thu, 15 Jul 2021 16:23:35 +0200 Subject: [PATCH] feat(velero): add possibility to specify a tenant list by cli --- hack/velero-restore.sh | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/hack/velero-restore.sh b/hack/velero-restore.sh index f53bf4f5..ebebc9e9 100755 --- a/hack/velero-restore.sh +++ b/hack/velero-restore.sh @@ -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 < "$TMPDIR/tenant_$tnt" { @@ -169,6 +176,10 @@ while :; do update_kube_options shift ;; + -t|--tenant) + TENANTS="${2}" + shift + ;; *) break esac