Skip to content

Conversation

@kpaulisse
Copy link
Contributor

This PR solves two reported issues regarding regular expression handling and ignores.

Fixes #175. Regular expressions were not supported for attributes which explains the error that was reported. Now regular expressions are supported.

Fixes #183. The "no newline at end of file" is now ignored if it appears in BOTH the "from" and "to" diffs because it's not really a difference in that case. (If it appears in one but not the other, it's still a difference, and it would need to be explicitly ignored.)

/cc @baurmatt who reported both of these issues. Care to give this branch a try with your use cases?

@baurmatt
Copy link

Thanks a lot! :)

Regarding #183: This is fixed for my example and now works as expected.

Regarding #175:
This seems to be kind of fixed as in: it isn't throwing errors anymore. But my change still isn't ignore.
Example:

mbaur@jumphost:~ $ Sources/syseleven-control/scripts/diffenvs/diffenvs -e mbaur -n server1234 --no-puppet
I, [2018-03-28T18:06:29.231143 #26699]  INFO -- : Running diffenvs for server1234 (production <=> mbaur)
  File[/etc/apache2/mods-available/mpm_prefork.conf] =>
   parameters =>
     group =>
      + test
     mode =>
      + 0666
     owner =>
      + test
*******************************************

The ignore list is configured as following:

catalog_diff_result = OctocatalogDiff::API::V1.catalog_diff(
  {
    :to_catalog   => catalog_new.path,
    :from_catalog => catalog_old.path,
    :ignore       => [
      {
        type: Regexp.new('\AFile\z'),
        attr: Regexp.new("\Aparameters\f(owner|group|mode)\z"),
      },
    ],
  }
)

@kpaulisse
Copy link
Contributor Author

kpaulisse commented Mar 29, 2018

attr: Regexp.new("\Aparameters\f(owner|group|mode)\z"),

Try this:

attr: Regexp.new("\\Aparameters\f(owner|group|mode)\\z"),

This may demonstrate what's going on:

irb(main):001:0> r = Regexp.new("\Akittens\z")
=> /Akittensz/
irb(main):002:0> r.match("kittens")
=> nil
irb(main):003:0> r = Regexp.new("\\Akittens\\z")
=> /\Akittens\z/
irb(main):004:0> r.match("kittens")
=> #<MatchData "kittens">

Edit: I've just pushed an update to the documentation to correct the examples and add this as a tip.

@baurmatt
Copy link

attr: Regexp.new("\Aparameters\f(owner|group|mode)\z"),

That does the trick. Thanks! :)

@kpaulisse
Copy link
Contributor Author

Testing within GitHub for a couple days, then I'll merge this.

@kpaulisse kpaulisse merged commit 8774031 into master Apr 2, 2018
@kpaulisse kpaulisse deleted the kpaulisse-regexp-attributes branch April 2, 2018 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants