From bb4b840630466bf6346681af73e216b43c3f429d Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Wed, 8 Nov 2023 17:07:24 +0100 Subject: [PATCH] fix(cli): proper defaults for dump (#1094) --- cmd/gateway_dump.go | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/cmd/gateway_dump.go b/cmd/gateway_dump.go index 5c3c72d88..65227b803 100644 --- a/cmd/gateway_dump.go +++ b/cmd/gateway_dump.go @@ -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 @@ -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", @@ -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 }