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

feat(state) support multiple files in args #137

Merged
merged 5 commits into from
Apr 3, 2020

Conversation

raittes
Copy link
Contributor

@raittes raittes commented Mar 31, 2020

Objective:

I have different state-directories for each environment (ex: production, staging)
And I want to have common configuration for both environments,
so I could create a symlink for a common directory inside each environment directory.
(ex: production/common -> ../common)

Problem:

Currently, deck-cli state flag (--state) supports only one argument that can be a file or directory.
As filepath.Walk does not follow symlinks, deck will ignore symlinks found in the state directory.

Solution:

Supporting multiple arguments in state flag, we could load multiple state from different locations, as:

deck diff -s common -s production
or 
deck diff -s common,production

@hbagdi
Copy link
Member

hbagdi commented Apr 1, 2020

Can you please add a test case in the file package?

@raittes
Copy link
Contributor Author

raittes commented Apr 1, 2020

done @hbagdi

Copy link
Member

@hbagdi hbagdi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One cosmetic change, otherwise looks good.

I was a little surprised to see how easy it was to add this.

cmd/sync.go Outdated
syncCmd.Flags().StringVarP(&syncCmdKongStateFile,
"state", "s", "kong.yaml", "file containing Kong's configuration. "+
syncCmd.Flags().StringSliceVarP(&syncCmdKongStateFile,
"state", "s", []string{"kong.yaml"}, "file containing Kong's configuration. "+
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's change the help test to instead:

file(s) containing Kong's configuration.
This flag can be specified multiple times for multiple files.
Use '-' to read from stdin.

Please note the line jumps. We want that in the --help output.
Please change this in all other commands as well.

assert := assert.New(t)
assert.Equal("-", filename)
assert.Equal("-", filenames[0])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an interesting case where some configuration can be specified via Stdin and other via flag.
I was considering to restrict - as standalone, meaning you either specify only file(s) or only Stdin.
I think it is okay to allow it.
Just leaving a thought. No changes required.

@hbagdi hbagdi merged commit d7094d5 into Kong:master Apr 3, 2020
@raittes
Copy link
Contributor Author

raittes commented Apr 3, 2020

Thank you @hbagdi!
When it will be released?

@hbagdi
Copy link
Member

hbagdi commented Apr 3, 2020

Expect a release in a couple of weeks.
There are a few other features in progress.

rainest pushed a commit that referenced this pull request Apr 21, 2021
AntoineJac pushed a commit that referenced this pull request Jan 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants