kastenhq / kubestr

Apache License 2.0
349 stars 47 forks source link

Adding --show-tree flag to both "./kubestr browse pvc" & "./kubestr browse snapshot" commands #278

Closed shlokc9 closed 2 months ago

shlokc9 commented 2 months ago

This PR adds a new flag --show-tree to both ./kubestr browse snapshot & ./kubestr browse snapshot commands which would enable the users to print the contents of a PVC and VolumeSnapshot in directory tree structure format.

Unit-tested these code changes with new fake tests and mock objects Tested these code changes by executing the command on a GKE cluster. Please find the output below;

> ./kubestr browse pvc test-pvc1 -n file-level-restore -v test-snapshotclass --show-tree
Taking a snapshot.
Creating the browser pod.
Printing the tree structure from root directory.

/pvc-data
├── lost+found
        └── abc.txt
└── time.txt

1 directories, 2 files

Cleaning up resources
> ./kubestr browse snapshot test-snapshot -n file-level-restore -s standard-rwo --show-tree
Fetching the snapshot.
Creating the browser pod.
Printing the tree structure from root directory.

/snapshot-data
├── lost+found
        └── abc.txt
└── time.txt

1 directories, 2 files

Cleaning up resources.

We follow the same cleanup procedure for browse snapshot & browse pvc. Which is;

  1. For browse pvc, we clean the snapshot, restore pvc and the browse pod
  2. For browse snapshot, we clean the restore pvc and the browse pod