Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): proper defaults for dump #1094

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 12 additions & 15 deletions cmd/gateway_dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,6 @@ func executeDump(cmd *cobra.Command, _ []string) error {

// Kong Enterprise dump all workspace
if dumpAllWorkspaces {
if dumpWorkspace != "" {
return fmt.Errorf("workspace cannot be specified with --all-workspace flag")
}
if dumpCmdKongStateFile != defaultFileOutName {
return fmt.Errorf("output-file cannot be specified with --all-workspace flag")
}
workspaces, err := listWorkspaces(ctx, wsClient)
if err != nil {
return err
Expand Down Expand Up @@ -170,15 +164,6 @@ configure Kong.`,
RunE: execute,
}

if deprecated {
dumpCmd.Flags().StringVarP(&dumpCmdKongStateFileDeprecated, "output-file", "o",
fileOutDefault, "file to which to write Kong's configuration."+
"Use `-` to write to stdout.")
} else {
dumpCmd.Flags().StringVarP(&dumpCmdKongStateFile, "output-file", "o",
fileOutDefault, "file to which to write Kong's configuration."+
"Use `-` to write to stdout.")
}
dumpCmd.Flags().StringVar(&dumpCmdStateFormat, "format",
"yaml", "output file format: json or yaml.")
dumpCmd.Flags().BoolVar(&dumpWithID, "with-id",
Expand All @@ -201,5 +186,17 @@ configure Kong.`,
false, "assume `yes` to prompts and run non-interactively.")
dumpCmd.Flags().BoolVar(&dumpConfig.SkipCACerts, "skip-ca-certificates",
false, "do not dump CA certificates.")
if deprecated {
dumpCmd.Flags().StringVarP(&dumpCmdKongStateFileDeprecated, "output-file", "o",
fileOutDefault, "file to which to write Kong's configuration."+
"Use `-` to write to stdout.")
} else {
dumpCmd.Flags().StringVarP(&dumpCmdKongStateFile, "output-file", "o",
fileOutDefault, "file to which to write Kong's configuration."+
"Use `-` to write to stdout.")
}
dumpCmd.MarkFlagsMutuallyExclusive("output-file", "all-workspaces")
dumpCmd.MarkFlagsMutuallyExclusive("workspace", "all-workspaces")

return dumpCmd
}
Loading