-
Notifications
You must be signed in to change notification settings - Fork 88
/
backup-ls.go
41 lines (34 loc) · 978 Bytes
/
backup-ls.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package cli
import (
"github.com/pkg/errors"
"github.com/replicatedhq/kots/pkg/print"
"github.com/replicatedhq/kots/pkg/snapshot"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
func BackupListCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "ls",
Short: "List available instance backups",
Long: ``,
SilenceUsage: true,
SilenceErrors: false,
PreRun: func(cmd *cobra.Command, args []string) {
viper.BindPFlags(cmd.Flags())
},
RunE: func(cmd *cobra.Command, args []string) error {
v := viper.GetViper()
options := snapshot.ListInstanceBackupsOptions{
Namespace: v.GetString("namespace"),
}
backups, err := snapshot.ListInstanceBackups(options)
if err != nil {
return errors.Wrap(err, "failed to list instance backups")
}
print.Backups(backups)
return nil
},
}
cmd.Flags().StringP("namespace", "n", "", "filter by the namespace in which kots/kotsadm is installed")
return cmd
}