-
Notifications
You must be signed in to change notification settings - Fork 351
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
config: add yaml flag #3069
config: add yaml flag #3069
Conversation
YAML flag parses (preferably flow-style) YAML value from the command line or unmarshals object yaml value from the yaml config file. Example value: ``` bin/skipper -foo-flag='{foo: hello, bar: [world, "1"], baz: 2, qux: {baz: 3}}' ``` and equivalent branch in config yaml: ```yaml foo-flag: foo: hello bar: - world - "1" baz: 2 qux: baz: 3 ``` This will be useful for #2104 It is also a better alternative to manual parsing of micro-syntax like e.g. implemented in #2888 Signed-off-by: Alexander Yastrebov <[email protected]>
2503211
to
174cd01
Compare
) | ||
|
||
type yamlFlag[T any] struct { | ||
Ptr **T |
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.
ouch :)
But I see why
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.
The usage looks like
type Config struct {
OpenTelemetry *otel.Options `yaml:"open-telemetry"`
...
}
...
flag.Var(newYamlFlag(&cfg.OpenTelemetry), "open-telemetry", "OpenTelemetry configuration in YAML format, use flow-style for convenience")
...
if o.OpenTelemetry != nil {
...
}
The value is allocated when flag is set and stays nil when it is not, i.e. this allows to tell if flag was provided.
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.
Yes I saw it, all good :)
👍 |
1 similar comment
👍 |
YAML flag parses (preferably flow-style) YAML value from the command line or unmarshals object yaml value from the yaml config file. Example value: ``` bin/skipper -foo-flag='{foo: hello, bar: [world, "1"], baz: 2, qux: {baz: 3}}' ``` and equivalent branch in config yaml: ```yaml foo-flag: foo: hello bar: - world - "1" baz: 2 qux: baz: 3 ``` This will be useful for zalando#2104 It is also a better alternative to manual parsing of micro-syntax like e.g. implemented in zalando#2888 Signed-off-by: Alexander Yastrebov <[email protected]>
YAML flag parses (preferably flow-style) YAML value from the command line or unmarshals object yaml value from the yaml config file.
Example value:
and equivalent branch in config yaml:
This will be useful for #2104
It is also a better alternative to manual parsing of micro-syntax like e.g. implemented in #2888