Skip to content

Ignoring attributes changes with a regex for non content parameter doesn't work as expected #183

@baurmatt

Description

@baurmatt

Description of problem

  • What did you do?
    Diffing two catalogs with OctocatalogDiff::API::V1.catalog_diff and ignoring the following change:
  File[/etc/snmp/snmpd.conf] =>
   parameters =>
     source =>
      - puppet:///modules/hardwarenode_base/snmpd.conf
      + puppet:///modules/hp_utilities/snmpd.conf

I've used the following ignore rule:

catalog_diff_result = OctocatalogDiff::API::V1.catalog_diff(
  {
    :logger       => logger,
    :to_catalog   => catalog_new.path,
    :from_catalog => catalog_old.path,
    :ignore       => [
      {
        type: 'File',
        title: '/etc/snmp/snmpd.conf',
        attr: "parameters\fsource=&>.*(hp_utilities|hardwarenode_base).*"
      },
    ]
  }
)

Command used and debugging output

Platform and version information

  • Your OS: Ubuntu 14.04.5
  • Your Ruby version: 2.4.0
  • Your version of Puppet: 5.3.4
  • Your version of octocatalog-diff: 1.5.2

Do the tests pass from a clean checkout?

Using the gem, so hopefully ;)

Anything else to add that you think will be helpful?

I think the problem is what's in the diff. If you add @logger.info line before https://github.com/github/octocatalog-diff/blob/master/lib/octocatalog-diff/catalog-diff/differ.rb#L298 the output is the following:

...
I, [2018-03-06T14:20:10.508543 #10136]  INFO -- : Catalogs compiled for
I, [2018-03-06T14:20:11.542122 #10136]  INFO -- : -puppet:///modules/hardwarenode_base/snmpd.conf

I, [2018-03-06T14:20:11.542181 #10136]  INFO -- : \ No newline at end of file

I, [2018-03-06T14:20:11.542208 #10136]  INFO -- : +puppet:///modules/hp_utilities/snmpd.conf

I, [2018-03-06T14:20:11.542238 #10136]  INFO -- : \ No newline at end of file

I, [2018-03-06T14:20:11.545826 #10136]  INFO -- : Diffs computed for
...

The problem seems to be the line \ No newline at end of file. If i change my OctocatalogDiff::API::V1.catalog_diff object to the following, the ignore works.

catalog_diff_result = OctocatalogDiff::API::V1.catalog_diff(
  {
    :logger       => logger,
    :to_catalog   => catalog_new.path,
    :from_catalog => catalog_old.path,
    :ignore       => [
      {
        type: 'File',
        title: '/etc/snmp/snmpd.conf',
        attr: "parameters\fsource=&>.*(hp_utilities|hardwarenode_base|No newline at end of file).*"
      },
    ]
  }
)

But this seems kind of non-intuitive, might be a good idea to automatically ignore those lines. On the other hand, in other scenarios there could be only this one line which someone wants to catch.

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions