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/convert #775

Merged
merged 3 commits into from
Oct 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,17 @@

### Added

- Add `--yes` flag to `convert` subcommand to bypass
user confirmation and run non-interactively.
[#775](https://github.com/Kong/deck/pull/775)
- Add support to Kong Vaults.
[#761](https://github.com/Kong/deck/pull/761)

### Fixes

- Use `kong.yaml` as default value with `convert` subcommand
when no `--output-file` is provided.
[#775](https://github.com/Kong/deck/pull/775)
- Add `-w` shorthand flag support to `sync`.
[#765](https://github.com/Kong/deck/pull/765)
- Handle correctly encoded whitespaces into services' `url`
Expand Down
9 changes: 7 additions & 2 deletions cmd/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var (
convertCmdDestinationFormat string
convertCmdInputFile string
convertCmdOutputFile string
convertCmdAssumeYes bool
)

// newConvertCmd represents the convert command
Expand All @@ -37,7 +38,9 @@ can be converted into a 'konnect' configuration file.`,
}

if convertCmdInputFile != "" {
if yes, err := utils.ConfirmFileOverwrite(convertCmdOutputFile, "", false); err != nil {
if yes, err := utils.ConfirmFileOverwrite(
convertCmdOutputFile, "", convertCmdAssumeYes,
); err != nil {
return err
} else if !yes {
return nil
Expand Down Expand Up @@ -80,8 +83,10 @@ can be converted into a 'konnect' configuration file.`,
fmt.Sprintf("desired format of the output, allowed formats: %v", destinationFormats))
convertCmd.Flags().StringVar(&convertCmdInputFile, "input-file", "",
"configuration file to be converted. Use `-` to read from stdin.")
convertCmd.Flags().StringVar(&convertCmdOutputFile, "output-file", "",
convertCmd.Flags().StringVar(&convertCmdOutputFile, "output-file", "kong.yaml",
"file to write configuration to after conversion. Use `-` to write to stdout.")
convertCmd.Flags().BoolVar(&convertCmdAssumeYes, "yes",
false, "assume `yes` to prompts and run non-interactively.")
return convertCmd
}

Expand Down