Skip to content
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

Handle multi doc rules files #760

merged 2 commits into from Aug 2, 2019

Handle multi doc rules files #760

merged 2 commits into from Aug 2, 2019


Copy link

mstemm commented Aug 1, 2019

What type of PR is this?

Uncomment one (or more) /kind <> lines:

/kind bug

/kind cleanup

/kind design

/kind documentation

/kind failing-test

/kind feature

/kind flaky-test

If contributing rules or changes to rules, please make sure to also uncomment one of the following line:

/kind rule-update

/kind rule-create

Any specific area of the project related to this PR?

Uncomment one (or more) /area <> lines:

/area engine

/area rules

/area deployment

/area integrations

/area examples

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

Handle multi-document yaml files when reading rules files.
mstemm added 2 commits Aug 1, 2019
Properly parse multi-document yaml files e.g. blocks separated by
---. This is easily handled by lyaml itself--you just need to pass the
option all = true to yaml.load, and each document will be provided as a table.

This does break the table iteration a bit, so some more refactoring:

 - Create a load_state table that holds context like the current
 - document index, the required_engine_version, etc.
 - Pull out the parts that parse a single document to load_rules_doc(),
   which is given the table for a single document + load_state.
 - Simplify get_orig_yaml_obj to just provide a single row index and
 - return all rows from that point to the next blank line or line
   starting with '-'

Signed-off-by: Mark Stemm <>
New automated tests for testing parsing of multiple-doc rules files:

 - invalid_{overwrite,append}_{macro,rule}_multiple_docs are just like
   the previous versions, but with the multiple files combined into a
   single multi-document file.

 - multiple_docs combines the rules file from multiple_rules

The expect the same results and output as the multiple-file versions.

Signed-off-by: Mark Stemm <>
@mstemm mstemm force-pushed the handle-multi-doc-rules-files branch from 5daaf06 to 598a8f4 Aug 1, 2019
leodido approved these changes Aug 2, 2019

This comment has been minimized.

Copy link

poiana commented Aug 2, 2019


This pull-request has been approved by: leodido

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@poiana poiana added the lgtm label Aug 2, 2019

This comment has been minimized.

Copy link

poiana commented Aug 2, 2019

LGTM label has been added.

Git tree hash: 6b456f0075afdb734cf6499759030634cff3cfea

@poiana poiana added the approved label Aug 2, 2019
@mstemm mstemm merged commit 94d89ea into dev Aug 2, 2019
6 of 7 checks passed
6 of 7 checks passed
tide Not mergeable. Job Travis CI - Pull Request has not succeeded.
Build Build Successful
Run tests All tests passed
Travis CI - Branch Build Passed
Travis CI - Pull Request Build Passed
continuous-integration/jenkins/branch This commit looks good
dco All commits have Signed-off-by
@mstemm mstemm deleted the handle-multi-doc-rules-files branch Aug 2, 2019
@leodido leodido added this to the 0.18.0 milestone Aug 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.