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

Deck always defaults to konnect.yaml instead of kong.yaml #288

Closed
cwurm opened this issue Mar 9, 2021 · 2 comments · Fixed by #290
Closed

Deck always defaults to konnect.yaml instead of kong.yaml #288

cwurm opened this issue Mar 9, 2021 · 2 comments · Fixed by #290
Assignees
Labels
bug Something isn't working

Comments

@cwurm
Copy link
Contributor

cwurm commented Mar 9, 2021

With decK 1.5 the default Kong configuration file is konnect.yaml and no longer kong.yaml. Reading the code, I believe this is a mistake? The non-Konnect commands still have kong.yaml as the default, e.g.

deck/cmd/dump.go

Lines 152 to 154 in a640f10

dumpCmd.Flags().StringVarP(&dumpCmdKongStateFile, "output-file", "o",
"kong", "file to which to write Kong's configuration."+
"Use '-' to write to stdout.")

However, the same variable names are used in the Konnect commands, e.g.

deck/cmd/konnect_dump.go

Lines 80 to 82 in a640f10

konnectDumpCmd.Flags().StringVarP(&dumpCmdKongStateFile, "output-file", "o",
"konnect", "file to which to write Kong's configuration."+
"Use '-' to write to stdout.")

What I think is happening is that the first thing StringVarP does is set the variable to the default value in https://github.com/spf13/pflag/blob/85dd5c8bc61cfa382fecd072378089d4e856579d/string.go#L6-L9

And since the Konnect files are alphabetically after the non-Konnect files their default value will always overwrite the non-Konnect values during package initialization.

The different commands should probably just use different variables to avoid any crossover.

@cwurm cwurm added the bug Something isn't working label Mar 9, 2021
rainest pushed a commit that referenced this issue Mar 11, 2021
Use separate variables to store Konnect command flag values where
Konnect commands share flags with non-Konnect commands.

Cobra will otherwise update the variable contents with whichever flags
it processes last, effectively overriding the non-Konnect defaults with
the Konnect defaults.

Fix #288
@rainest
Copy link
Contributor

rainest commented Mar 11, 2021

Particularly annoying for dump because of the way the --all-workspaces sanity check works. The value is konnect regardless of which command you're using, so it fails on 1.5:

$ ./deck14 dump --all-workspaces
$ ./deck15 dump --all-workspaces 
Error: output-file cannot be specified with --all-workspace flag

A temporary workaround for 1.5 is to explicitly specify the old default. Even though it's not used for the filenames, it allows the check to pass and continues on to create the workspace filenames normally:

$ ./deck15 dump --all-workspaces -o kong

@danielkocot
Copy link

danielkocot commented Mar 19, 2021

I use deck a lot in CI/CD contexts.

  • For validate it has to be kong.yaml
  • diff needs a konnect.yaml
  • And sync needs a kong.yaml again

It would nice to have the opportunity to flag the name of config file on demand. As a workaround I always use mv on bash.

mflendrich pushed a commit that referenced this issue Mar 19, 2021
Use separate variables to store Konnect command flag values where
Konnect commands share flags with non-Konnect commands.

Cobra will otherwise update the variable contents with whichever flags
it processes last, effectively overriding the non-Konnect defaults with
the Konnect defaults.

Fix #288
rainest pushed a commit that referenced this issue Apr 21, 2021
Use separate variables to store Konnect command flag values where
Konnect commands share flags with non-Konnect commands.

Cobra will otherwise update the variable contents with whichever flags
it processes last, effectively overriding the non-Konnect defaults with
the Konnect defaults.

Fix #288
AntoineJac pushed a commit that referenced this issue Jan 23, 2024
Use separate variables to store Konnect command flag values where
Konnect commands share flags with non-Konnect commands.

Cobra will otherwise update the variable contents with whichever flags
it processes last, effectively overriding the non-Konnect defaults with
the Konnect defaults.

Fix #288
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants