(PUP-4629) Return values instead of augeas paths during the match operation#3952
Conversation
8aa8fe2 to
a37cb80
Compare
|
CLA signed by all contributors. |
a37cb80 to
1f64f39
Compare
|
I can see where you're going with this, but changing the behaviour of I would suggest adding a |
Oh, we do have it, apologies. Maybe call it something else then if you'd like support for returning an array of values, e.g. |
|
Adding a I would argue that the If we are trying to make the controls in |
|
I'd say that's a documentation bug and that changing the provider behaviour is a) going to be incompatible, so would have to live in master for some time, and b) would differ from Augeas. I think mimicking Augeas' API is quite important, as many users will test how Augeas responds via augtool, so to change the return value from a standard API call or command is surprising. This is a very useful feature, particularly so the |
|
Fair enough |
|
If we are trying to mimic augeas commands exactly -- how should getm be implemented? There does not seem to be a built in getm command. It seems running a |
|
Yes, that'd be the way to do it. |
|
Hi @mmarod Thanks for pushing up a new commit! Would you mind squashing the two commits into one (basically amending the original commit)? |
1528450 to
14c5e4b
Compare
There was a problem hiding this comment.
It doesn't affect the code, but for clarity, change match to getm. (Ditto below.)
|
Looks good to me. Would you also mind adding the |
37fac9a to
3b9f816
Compare
|
👍 looks good, and tests well. |
|
Oh, the only thing I'd add is that the commit message doesn't quite reflect what it does any more, since the |
3b9f816 to
04a21c7
Compare
|
I am a little late to the party, but how about calling that new operator |
|
|
|
Good suggestion, works for me! |
9652880 to
58f52cf
Compare
|
Looks fine to me, although the commit message is incorrect again, s/getm/values/. Could be fixed on merge. |
58f52cf to
35cee76
Compare
|
Fixed the commit message again |
|
👍 thanks @mmarod! |
lib/puppet/provider/augeas/augeas.rb
Outdated
There was a problem hiding this comment.
Could this loop be replaced by an invocation of Array#map aka #collect?
dc0199b to
7ef9afd
Compare
|
The appveyor failures are a known issue https://tickets.puppetlabs.com/browse/PUP-4537 and can be ignored. |
|
So it's been a while since this is seemingly ready to go -- What is the hold up? |
|
@mmarod We've had to cancel the last three community PR triage sessions while preparing for the Puppet 4.2.0 release. We'll resume next 10am PDT, Wednesday, June 1, so it should be merged soon. |
|
@mmarod one minor nit, could you update the commit message to describe how |
7ef9afd to
1c8c87a
Compare
|
@mmarod thanks for updating that, the example is very helpful. Could you shorten the subject line to follow our convention as described in https://github.com/puppetlabs/puppet/blob/master/CONTRIBUTING.md: I'm happy to fix that up if you're busy. Thank you again! |
1c8c87a to
f7e35ac
Compare
|
No problem -- Let me know how it looks. |
f7e35ac to
81f2378
Compare
This patch allows comparisons against values. Previously, comparisons
could only be performed against labels.
Example usage would be to ensure that augeas only runs if the values of
cfg_file using the Nagios lens do not match a list of known values.
augeas { 'configure-nagios-cfg_file':
incl => '/etc/nagios/nagios.cfg',
lens => 'NagiosCfg.lns',
changes => [ "rm cfg_file",
"ins cfg_file",
"set cfg_file[1] /etc/nagios/commands.cfg",
"ins cfg_file after /files/etc/nagios/nagios.cfg/cfg_file[last()]",
"set cfg_file[2] /etc/nagios/anotherconfig.cfg" ],
onlyif => "values cfg_file != ['/etc/nagios/commands.cfg', '/etc/nagios/anotherconfig.cfg']"
}
81f2378 to
f8ddf88
Compare
|
Thank you @mmarod for your contribution! This will be released in puppet 4.3.0. |
This fixes PUP-4629 by using aug.get to return the values of the paths returned by the aug.match operation.