Skip to content

Commit

Permalink
support -n in list commands
Browse files Browse the repository at this point in the history
  • Loading branch information
majodev committed Jan 15, 2025
1 parent 8ec81cd commit f9a0806
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-test-publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,11 @@ jobs:
&& BACKUP_NS_TMP="$(mktemp -d)" \
&& cd "${BACKUP_NS_TMP}" \
&& ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/')" \
&& curl -fsSLO "https://github.com/allaboutapps/backup-ns/releases/download/v${BACKUP_NS_VERSION}/backup-ns-linux-${ARCH}.tar.gz" \
&& curl -fsSLO "https://github.com/allaboutapps/backup-ns/releases/download/${BACKUP_NS_VERSION}/backup-ns-linux-${ARCH}.tar.gz" \
&& tar zxvf "backup-ns-linux-${ARCH}.tar.gz" \
&& chmod +x "backup-ns-linux-${ARCH}" \
&& cp "backup-ns-linux-${ARCH}" /usr/local/bin/backup-ns \
&& curl -fsSLO "https://github.com/allaboutapps/backup-ns/releases/download/v${BACKUP_NS_VERSION}/create-adhoc-backup.sh.tar.gz" \
&& curl -fsSLO "https://github.com/allaboutapps/backup-ns/releases/download/${BACKUP_NS_VERSION}/create-adhoc-backup.sh.tar.gz" \
&& tar zxvf "create-adhoc-backup.sh.tar.gz" \
&& chmod +x create-adhoc-backup.sh \
&& cp create-adhoc-backup.sh /usr/local/bin/ \
Expand Down
9 changes: 7 additions & 2 deletions cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ var vsListCmd = &cobra.Command{
Use: "list",
Short: "List volume snapshots with backup-ns labels",
Run: func(_ *cobra.Command, args []string) {
namespace := ""
if !allNamespaces {
// Handle namespace selection
if allNamespaces && namespace != "" {
log.Fatal("Cannot specify both --namespace and --all-namespaces")
}

if !allNamespaces && namespace == "" {
var err error
namespace, err = lib.GetCurrentNamespace()
if err != nil {
Expand Down Expand Up @@ -82,6 +86,7 @@ var vsListCmd = &cobra.Command{
func init() {
rootCmd.AddCommand(vsListCmd)
vsListCmd.Flags().BoolVarP(&allNamespaces, "all-namespaces", "A", false, "List volume snapshots in all namespaces")
vsListCmd.Flags().StringVarP(&namespace, "namespace", "n", "", "Namespace to list snapshots from (defaults to current namespace)")
vsListCmd.Flags().BoolVar(&filterDaily, "daily", false, "Filter daily snapshots")
vsListCmd.Flags().BoolVar(&filterWeekly, "weekly", false, "Filter weekly snapshots")
vsListCmd.Flags().BoolVar(&filterMonthly, "monthly", false, "Filter monthly snapshots")
Expand Down

0 comments on commit f9a0806

Please sign in to comment.