(PUP-11315) Allow resource attributes named "plan" and "apply"#8781
Conversation
2d54440 to
14c3df5
Compare
|
This came up because of https://github.com/hercules-team/augeasproviders_sysctl which defines a parameter called |
| context 'it should allow keywords as attribute names' do | ||
| ['and', 'case', 'class', 'default', 'define', 'else', 'elsif', 'if', 'in', 'inherits', 'node', 'or', | ||
| 'undef', 'unless', 'type', 'attr', 'function', 'private'].each do |keyword| | ||
| 'undef', 'unless', 'type', 'attr', 'function', 'private', 'plan', 'apply'].each do |keyword| |
There was a problem hiding this comment.
These tests actually pass without the change, because :tasks is false.
14c3df5 to
4c940ed
Compare
|
Does this need to target 6.x? |
lucywyman
left a comment
There was a problem hiding this comment.
Confirmed this addresses the original issue of apply in a Puppet resource erroring inside Bolt plans 🙌🏼
|
I do think this needs to land in 6.x so we can use it in PE. |
Previously, using either of these keywords as resource attribute names within an apply() block in a plan would fail. That happened because they weren't included in the `keyword` rule. This was only a problem when running in a plan, because those keywords only exist when the `tasks` setting is set. In normal Puppet operation, they aren't lexed as special tokens at all, so they didn't need to be in the `keyword` rule to function properly. We now add them to the `keyword` rule regardless of whether they are actually lexed as keywords, which works fine in both cases.
This was done with `bundle exec rake gen_eparser`.
4c940ed to
4fba2bb
Compare
|
Rebased and retargeted at 6.x |
|
Lemme try closing and reopening to rekick the checks |
|
Ignore the appyeyor issue, I think it's just confused from the rebase. I'm not super familiar with the lexer/parser, so to make sure I understand, PUP-8977 added the Is the general rule that all I also noticed the grammar defines a |
|
This case is particularly confusing because the grammar is static but the lexer varies based on whether If When This change adds that token to You're right that the general rule is that all keywords need to be in I'm not sure exactly what the Because the use of |
joshcooper
left a comment
There was a problem hiding this comment.
Ahh, thanks @nicklewis for a great explanation! I missed that the attribute_name rule produced a NAME or keyword. But yeah makes sense.
Previously, using either of these keywords as resource attribute names
within an apply() block in a plan would fail. That happened because they
weren't included in the
keywordrule. This was only a problem whenrunning in a plan, because those keywords only exist when the
taskssetting is set. In normal Puppet operation, they aren't lexed as special
tokens at all, so they didn't need to be in the
keywordrule to functionproperly.
We now add them to the
keywordrule regardless of whether they areactually lexed as keywords, which works fine in both cases.