-
Notifications
You must be signed in to change notification settings - Fork 905
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
support arbitrary-depth nested values in YAML configuration #1792
support arbitrary-depth nested values in YAML configuration #1792
Conversation
This is a change of direction from the current design, that imposes loading the configuration from file only, and in the object constructor. Instead, yaml_configuration objects can now be reused ad can load the YAML config from either file or string. This also makes it easier to unit test this class. Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
Since now, the maximum depth supported to access config fields is two. This adds support for accessing fields of arbitrary nesting depth. A formal grammar has been explicited for the regular language representing the field keys. The accessor methods have been updated accordingly. Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
…node Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
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.
/approve
whoa! 👏
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jasondellaluce, leogr The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
LGTM label has been added. Git tree hash: d13411f968ca63f8443fa1075da6c9e33e6ecc12
|
/milestone 0.31.0 |
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.
Looks like a valuable change. It's very similar to json pointers, but for yaml!
This fixes the parser introduced in #1792. Now, nested fields such as `arr[1].subval` are supported, whereas the parser used to recognize the `.` as an unexpected character. Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
This fixes the parser introduced in #1792. Now, nested fields such as `arr[1].subval` are supported, whereas the parser used to recognize the `.` as an unexpected character. Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
What type of PR is this?
/kind design
/kind feature
Any specific area of the project related to this PR?
/area engine
/area tests
What this PR does / why we need it:
Falco loads its configuration from a YAML file. However, we currently support fields with a maximum depth of 2. Fields nested after the second level are not reachable programmatically. This is a limiter for future features and contributions. At the same time, the current code only loads the configuration from file, which makes it impossible to write unit tests for the configuration loader.
This PR introduces a representation-agnostic notation to access configuration fields, independently from their level of nesting and from their underlying representation (YAML or others). Accordingly, the
yaml_configuration
class has been slightly refactored to address this changes.Unit tests have been implement to assert that everything works as expected.
Which issue(s) this PR fixes:
Special notes for your reviewer:
The newly proposed syntax for accessing config fields resembles the way nested objects are accessed in JSON. Consider the following YAML file:
Each field can be accessed as:
Does this PR introduce a user-facing change?: