def find_labeled(labels, match_any = Config.transient[:alert_match_any]) # rubocop: disable AbcSize
      list = list_labels
      labeled = []
      Array(labels).select do |lbl|
        list.select { |x| x['key'].casecmp(lbl).zero? }.each do |mtch|
          labeled.push(Array(mtch['links']['servers']))
        end
      end

      unless match_any
        # => Array(labeled) should contain one array per label
        # => # => If it does not, it means the label is missing or misspelled
        return [] unless labeled.count == Array(labels).count

        # => Return Only those matching All Labels
        return Util.common_array(labeled)
      end
      labeled.flatten.uniq
    end
def find_labeled(labels, match_any = Config.transient[:alert_match_any]) 
      list = list_labels
      labeled = []
      Array(labels).select do |lbl|
        list.select { |x| x['key'].casecmp(lbl).zero? }.each do |mtch|
          labeled.push(Array(mtch['links']['servers']))
        end
      end

      unless match_any
        
        
        return [] unless labeled.count == Array(labels).count

        
        return Util.common_array(labeled)
      end
      labeled.flatten.uniq
    end
def find_labeled ( labels , match_any = Config . transient [ :alert_match_any ] ) # rubocop: disable AbcSize list = list_labels labeled = [ ] Array ( labels ) . select do | lbl | list . select { | x | x [ 'key' ] . casecmp ( lbl ) . zero? } . each do | mtch | labeled . push ( Array ( mtch [ 'links' ] [ 'servers' ] ) ) end end unless match_any # => Array(labeled) should contain one array per label # => # => If it does not, it means the label is missing or misspelled return [ ] unless labeled . count == Array ( labels ) . count # => Return Only those matching All Labels return Util . common_array ( labeled ) end labeled . flatten . uniq end
=> Find Servers Matching a Label
 => Example: find_labeled(['Role:API', 'Environment:Production'])
= > Find Servers Matching a Label = > Example : find_labeled ( [ Role : API Environment : Production ] )