Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Config File Syntax: Extend Embedded Ruby Code support for Hashes and …
…Arrays (#4580) Support [Embedded Ruby Code](https://docs.fluentd.org/configuration/config-file#embedded-ruby-code) for Hashes and Arrays. ``` key ["foo","#{1 + 1}"] => key ["foo","2"] key {"foo":"#{1 + 1}"} => key {"foo":"2"} ``` This is not backward compatible. We can disable this feature by surrounding the entire value with single quotes. ``` key `["foo","#{1 + 1}"]` => key ["foo","#{1 + 1}"] key `{"foo":"#{1 + 1}"}` => key {"foo":"#{1 + 1}"} ``` **Note: this feature is for JSON literals** This feature is for literals that using `[]` or `{}`. * We need to sort out the `literal` and `value` of the Fluentd Config Syntax. * Fluentd first interprets `literal` by parsing the config file. * `literal` is String or JSON. * Then, Fluentd interprets `value` by parsing the `literal`. * `value` has [various types](https://docs.fluentd.org/configuration/config-file#supported-data-types-for-values). * **This feature has nothing to do with parsing the `value`.** For example, we can specify Array/Hash `value` by using **String** `literal` We don't necessarily need to use **JSON** `literal` to specify Array/Hash `value`. The following formats works from previous versions, and there is no specification change at all. ``` key foo,bar key foo:bar key "foo,#{1 + 1}" key "foo:#{1 + 1}" ``` **Note: support only String of JSON** For example, this does not support Number of JSON. ``` key ["foo",2] => key ["foo",2] key ["foo",#{1 + 1}] => ERROR ``` It is because JSON `literal` supports multiple lines and comments. `#` not in String is considered the start of a comment line. ``` key ["foo", # comment "bar", # comment "boo" # comment ] ``` Signed-off-by: Athish Pranav D <[email protected]>
- Loading branch information