Support configuration files#462
Conversation
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
yurishkuro
left a comment
There was a problem hiding this comment.
overall looks like a great feature, but it looks like it could've been done with a lot less duplication by making it the default behavior of the SharedFlags
| v, | ||
| command, | ||
| flags.AddConfFileFlag, | ||
| flags.AddFlags, |
There was a problem hiding this comment.
any reason not to have config flag added as part of AddFlags? It would probably also avoid duplicating the code in L65-71 in all binaries, only do it in sFlags := new(flags.SharedFlags).InitFromViper(v)
There was a problem hiding this comment.
I did a split for two reasons:
- agent does use
flags.AddFlags flags.AddFlagscan be specified in config file, so there would be twicesFlags := new(flags.SharedFlags).InitFromViper(v)
There was a problem hiding this comment.
I see - makes sense. In that case can we move L65-71 into that package too, so that we can have just a one liner in the mains? E.g. something like flags.TryLoadConfigFile(v, logger)
There was a problem hiding this comment.
also, by doing that we can make flags.ExternalConfFlags type private. I suggest renaming it to ConfigFile(Flag) ("external" is non-informative)
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
cmd/flags/flags.go
Outdated
| v.SetConfigFile(file) | ||
| err := v.ReadInConfig() | ||
| if err != nil { | ||
| logger.Fatal(fmt.Sprintf("Fatal error config file: %s \n", file), zap.Error(err)) |
There was a problem hiding this comment.
Nit: don't use string formating. File name can be passed as a string field. Message could be "error loading config".
cmd/query/main.go
Outdated
| config.AddFlags( | ||
| v, | ||
| command, | ||
| flags.AddConfFileFlag, |
There was a problem hiding this comment.
Nit: s/conf/config for making consistency
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
* Support configuration files Signed-off-by: Pavol Loffay <ploffay@redhat.com> * Fix review comments Signed-off-by: Pavol Loffay <ploffay@redhat.com> * rename to AddConfigFileFlag Signed-off-by: Pavol Loffay <ploffay@redhat.com> * Add config file name to logs Signed-off-by: Pavol Loffay <ploffay@redhat.com>
* Support configuration files Signed-off-by: Pavol Loffay <ploffay@redhat.com> * Fix review comments Signed-off-by: Pavol Loffay <ploffay@redhat.com> * rename to AddConfigFileFlag Signed-off-by: Pavol Loffay <ploffay@redhat.com> * Add config file name to logs Signed-off-by: Pavol Loffay <ploffay@redhat.com>
Support configuration files. This allows us to configure Jaeger with kubernetes config maps.
By default configuration files are disabled. Lists are currently not handled because we parse them manually. For instance
cassandra.serversrequires a string with comma separated values.Follows some examples. Note that flags with dots can be written as nested objects.
{ "query": { "prefix": "prefix", "static-files": "static" }, "cassandra": { "keyspace": "from_file", "password": "pas_from_file", "servers": "localhost,localhost2", "archive": { "keyspace": "archive_keyspace" } }, "es.archive.max-span-age": "75h0m0s" }