Skip to content

Conversation

@isaiahfrantz
Copy link

…oth catalogs

Pass from_resources and to_resources to filter options, add logic to detect files with ensure=>absent in both catalogs, and suppress all parameter diffs for those files. Maintains backward compatibility by checking ensure diffs when resource lists are not provided.

Summary

When the AbsentFile filter is enabled, octocatalog-diff should not show diffs for resources that are ensure => absent in both catalogs, even if other parameters differ. If both sides are absent for the same resource key, those parameter differences are meaningless and should be suppressed.

This PR fixes a case where we would still emit diffs when both catalogs had ensure == absent but other params differed.

Problem

Today, AbsentFile filtering primarily triggers based on seeing an explicit ensure diff (e.g., present -> absent). If a file is absent in both catalogs, there may be no ensure diff at all, but we could still show diffs for other parameters (owner/mode/etc.) if they change.

That output is noise: if the file is absent in both catalogs, the params don’t matter.

Changes

Pass full resource lists to filters

  • Updated lib/octocatalog-diff/catalog-diff/differ.rb to pass:
    • from_resources: @catalog1_raw.resources
    • to_resources: @catalog2_raw.resources
      into the filter options hash.
  • This allows filters to reason about the full catalog state, not just diff hunks.

Improve AbsentFile filter behavior

  • Updated lib/octocatalog-diff/catalog-diff/filter/absent_file.rb:
    • The filter now tracks files that are absent in:
      • the to catalog
      • the from catalog
      • both catalogs
    • If a file is absent in both catalogs, the filter suppresses all diffs for that file (even if other params differ).
    • Preserved backwards-compatible behavior where an explicit ensure => absent diff in the new catalog is still sufficient to trigger filtering even when resource lists aren’t provided.

Tests

  • Added coverage to ensure diffs are suppressed when the same file is absent in both catalogs:
    • spec/octocatalog-diff/tests/catalog-diff/filter/absent_file_spec.rb

Run:

bundle exec rspec spec/octocatalog-diff/tests/catalog-diff/filter/absent_file_spec.rb

…oth catalogs

Pass from_resources and to_resources to filter options, add logic to detect files with ensure=>absent in both catalogs, and suppress all parameter diffs for those files. Maintains backward compatibility by checking ensure diffs when resource lists are not provided.
@isaiahfrantz
Copy link
Author

@ngrundy can you take a look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant