Skip to content

Commit

Permalink
chore(dump): Deprecate --directory (-C) flag in favor of position…
Browse files Browse the repository at this point in the history
…al arg
  • Loading branch information
gabe565 committed May 1, 2024
1 parent 8bac9ea commit 67cc4c5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
11 changes: 4 additions & 7 deletions cmd/dump/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/clevyr/kubedb/internal/database"
"github.com/clevyr/kubedb/internal/storage"
"github.com/clevyr/kubedb/internal/util"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
Expand Down Expand Up @@ -101,13 +102,9 @@ func preRun(cmd *cobra.Command, args []string) error {
if len(args) > 0 {
action.Filename = args[0]
}

if action.Directory != "" {
cmd.SilenceUsage = true
if err := os.Chdir(action.Directory); err != nil {
return err
}
cmd.SilenceUsage = false
if action.Directory != "" && action.Directory != "." {
log.Warn().Msg("Flag --directory has been deprecated, please pass the directory as a positional arg instead.")
action.Filename = filepath.Join(action.Directory, action.Filename)
}

if err := util.DefaultSetup(cmd, &action.Global, setupOptions); err != nil {
Expand Down
1 change: 0 additions & 1 deletion docs/kubedb_dump.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ kubedb dump [filename | bucket URI] [flags]
--create-job Create a job that will run the database client (default true)
--create-network-policy Creates a network policy allowing the KubeDB job to talk to the database. (default true)
-d, --dbname string Database name to use (default discovered)
-C, --directory string Directory to dump to (default ".")
-T, --exclude-table strings Do NOT dump the specified table(s)
-D, --exclude-table-data strings Do NOT dump data for the specified table(s)
-F, --format string Output file format One of (gzip|custom|plain) (default "gzip")
Expand Down
4 changes: 4 additions & 0 deletions internal/config/flags/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ func Directory(cmd *cobra.Command, p *string) {
if err != nil {
panic(err)
}

if err := cmd.Flags().MarkHidden(consts.DirectoryFlag); err != nil {
panic(err)
}
}

0 comments on commit 67cc4c5

Please sign in to comment.