Class: OctocatalogDiff::CatalogDiff::Filter::AbsentFile

Inherits:
OctocatalogDiff::CatalogDiff::Filter show all
Defined in:
lib/octocatalog-diff/catalog-diff/filter/absent_file.rb

Overview

Filter out changes in parameters when the “to” resource has ensure => absent.

Constant Summary collapse

KEEP_ATTRIBUTES =
(Set.new %w(ensure backup force provider)).freeze

Constants inherited from OctocatalogDiff::CatalogDiff::Filter

AVAILABLE_FILTERS

Instance Attribute Summary

Attributes inherited from OctocatalogDiff::CatalogDiff::Filter

#logger

Instance Method Summary collapse

Methods inherited from OctocatalogDiff::CatalogDiff::Filter

apply_filters, assert_that_filter_exists, filter, filter?

Constructor Details

#initialize(diffs, _logger = nil) ⇒ AbsentFile

Constructor: Since this filter requires knowledge of the entire array of diffs, override the inherited method to store those diffs in an instance variable.

Parameters:


18
19
20
21
# File 'lib/octocatalog-diff/catalog-diff/filter/absent_file.rb', line 18

def initialize(diffs, _logger = nil)
  @diffs = diffs
  @results = nil
end

Instance Method Details

#filtered?(diff, _options = {}) ⇒ Boolean

Public: If a file has ensure => absent, there are certain parameters that don't matter anymore. Filter out any such parameters from the result array. Return true if the difference is in a resource where `ensure => absent` has been declared. Return false if they this is not the case.

Parameters:

Returns:

  • (Boolean)

    true if this difference is a YAML file with identical objects, false otherwise


31
32
33
34
# File 'lib/octocatalog-diff/catalog-diff/filter/absent_file.rb', line 31

def filtered?(diff, _options = {})
  build_results if @results.nil?
  @results.include?(diff)
end