-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[cli/serve] accept mulitple --config flags #6825
[cli/serve] accept mulitple --config flags #6825
Conversation
|
||
_.each(deprecatedSettings, function (message, setting) { | ||
if (_.has(file, setting)) console.error(message); | ||
const files = [].concat(paths).map(path => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you doing the .concat()
here just to create a shallow copy? If so, it's not necessary because the .map()
creates a new array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm doing it to support receiving both an array of paths or a single path.
d58fa8f
to
9a6379f
Compare
…/multipleConfigFlags
jenkins, test it |
}; | ||
|
||
// transform legeacy options into new namespaced versions | ||
export function rewriteDeprecatedConfig(object) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you write some unit tests for this? I know the unit tests from read_yaml_config are at least partially covering this, but it really should have some tests of its own. Since it's not used anywhere else except in read_yaml_config at the moment and this PR is blocking other pull requests, I'm OK with not blocking on this, but can you at least follow up with another PR to add tests for it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'Path to the config file, can be changed with the CONFIG_PATH environment variable as well', | ||
process.env.CONFIG_PATH || fromRoot('config/kibana.yml')) | ||
'Path to the config file, can be changed with the CONFIG_PATH environment variable as well. ' + | ||
'Use mulitple --config flags to include multiple config files.', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since these aren't really flags, perhaps "multiple --config arguments" would be better?
274d917
to
23e4902
Compare
jenkins, test it |
So much fun. |
jenkins, test it |
// join them with simple string concatenation so that | ||
// compound keys don't get considered a single path segment | ||
(function recurse(obj, parent = []) { | ||
forOwn(obj, (val, leaf) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is new, right? I didn't just miss it in the old implementation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, this is new because we are now checking for deprecation before merging... Which now that I say it makes me think we should check for deprecation after merging...
d05c099
to
5a100b3
Compare
jenkins, test it |
// are checked for after the config object is prepared and known, so legacySettings | ||
// will have already been transformed. | ||
export const deprecatedSettings = new Map([ | ||
[['server', 'xsrf', 'token'], 'server.xsrf.token is deprecated. It is no longer used when providing xsrf protection.'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given how this data will be used, I think a simple hash would be better here.
- The inputs are private and won't be changing at runtime.
- You never need to do things like access the "size" of the collection.
- The key/value pairs are entered by humans and are likely to be the thing changing most frequently in this file over time.
So basically, the Map
here seems to be optimizing for CPU time rather than for humans, which I don't think is the right priority in this file.
Of course, objects can't have arrays as keys, but that brings me to my next point: I think these keys should be strings instead of arrays. Again, optimizing for humans.
I sort of think about these key/values as configuration data rather than programmatic values. For the sake of fewer moving parts and a simpler and less-bug-prone implementation, I don't suggest that we pull them out into an actual configuration file or anything, but treating them as if they could have come from a configuration file seems appropriate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I'm using Map
because _.has()
starts by doing a hasOwnProperty()
check, and therefore this test fails when I use string keys. It seems really weird to me that the function would work for direct properties and expanded properties, but not partially expanded properties considering the way that the rest of the configuration works.
If you think that it's worth it to prevent the use of Map()
and have this weird behavior I can live with it, but it's not really a cost to me. Map()
is no longer foreign to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I didn't see that test. Can you explain what "ignoring" does in this context? Maybe my brain is just fried this late in the day, but I'm struggling to make sense of it. Why would the "compoundedness" of the key determine whether a configuration should be considered deprecated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It just means that these would warn:
checkForDeprecatedConfig({ 'server.xsrf.token': 1 })
checkForDeprecatedConfig({ server: { xsrf: { token: 1 } } })
But these would not log a warning (all though they are valid ways to specify config):
checkForDeprecatedConfig({ 'server.xsrf': { token: 1 } })
checkForDeprecatedConfig({ server: { 'xsrf.token': 1 } })
So instead it just doesn't work with compound properties.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But... why would we want to ignore valid ways to specify a config?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function only runs on the fully expanded version of the config, the version that comes out of merge()
, so this discussion is just about what this function will do if someone includes this module outside of where it's currently used. I could also revert to the previous recursive flattening that worked for all key types if you prefer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are the drawbacks to that? I do think this should work for any valid way to configure a key.
If that means that you must pass a fully normalized/merged config, then I think that's completely fine, but it should probably throw an exception if it were given anything else rather than silently ignoring them.
491f640
to
5a100b3
Compare
Talked with @epixa about this offline, and we both agree that this discussion has been off in the weeds for a little while. In the interest of not blocking other work this is going in. |
When parsing the CLI arguments we should allow passing the
--config
flag multiple times so that multiple configuration files can be used. This allows enabling use of thekibana.dev.yml
file with the production build using:# mulitple files are merged in order, last one "wins" conflicts ./bin/kibana --config=config/kibana.yml --config=config/kibana.dev.yml