-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enabling remote restore in different namespace
Signed-off-by: mayank <[email protected]>
- Loading branch information
mayank
committed
Apr 24, 2020
1 parent
837917c
commit bed99ce
Showing
6 changed files
with
199 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package velero | ||
|
||
import ( | ||
"sort" | ||
|
||
"github.com/pkg/errors" | ||
"github.com/sirupsen/logrus" | ||
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// GetRestoreNamespace return the namespace mapping for the given namespace | ||
func GetRestoreNamespace(ns, bkpName string, log logrus.FieldLogger) (string, error) { | ||
listOpts := metav1.ListOptions{} | ||
list, err := clientSet.VeleroV1().Restores(veleroNs).List(listOpts) | ||
if err != nil { | ||
return "", errors.Wrapf(err, "failed to get list of restore") | ||
} | ||
|
||
sort.Sort(sort.Reverse(RestoreByCreationTimestamp(list.Items))) | ||
|
||
for _, r := range list.Items { | ||
if r.Status.Phase == velerov1api.RestorePhaseInProgress && r.Spec.BackupName == bkpName { | ||
targetedNs, ok := r.Spec.NamespaceMapping[ns] | ||
if ok { | ||
return targetedNs, nil | ||
} | ||
return ns, nil | ||
} | ||
} | ||
return "", errors.Errorf("restore not found for backup %s", bkpName) | ||
} |
Oops, something went wrong.