Module: Sensu::Plugins::Kubernetes::Exclude

Defined in:
lib/sensu-plugins-kubernetes/exclude.rb

Overview

A mixin module that provides filtering functions.

Instance Method Summary collapse

Instance Method Details

#node_excluded?(node_name) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/sensu-plugins-kubernetes/exclude.rb', line 25

def node_excluded?(node_name)
  config[:exclude_nodes].include?(node_name)
end

#node_included?(node_name) ⇒ Boolean

Filters the list of pods or nodes based on include/exclude options.

Parameters:

  • options (Hash)

    a customizable set of options

Returns:

  • (Boolean)


17
18
19
20
21
22
23
# File 'lib/sensu-plugins-kubernetes/exclude.rb', line 17

def node_included?(node_name)
  if config[:include_nodes].empty?
    true
  else
    config[:include_nodes].include?(node_name)
  end
end

#should_exclude_node(node_name) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/sensu-plugins-kubernetes/exclude.rb', line 29

def should_exclude_node(node_name)
  if node_name.nil?
    false
  else
    node_excluded?(node_name) || !node_included?(node_name)
  end
end