Class: Kubeclient::Common::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/picsolve_docker_builder/helpers/kubeclient.rb

Overview

Hot fix for kubeclient should be going upstream

Instance Method Summary collapse

Instance Method Details

#get_entities(entity_type, klass, options) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/picsolve_docker_builder/helpers/kubeclient.rb', line 8

def get_entities(entity_type, klass, options)
  params = {}
  if options[:label_selector]
    params['params'] = { labelSelector: options[:label_selector] }
  end

  ns_prefix = build_namespace_prefix(options[:namespace])
  response = handle_exception do
    rest_client[ns_prefix + resource_name(entity_type)]
    .get(params.merge(@headers))
  end

  result = JSON.parse(response)

  resource_version = result.fetch('resourceVersion', nil)
  if resource_version.nil?
    resource_version =
      result.fetch('metadata', {}).fetch('resourceVersion', nil)
  end

  collection = result['items'].map { |item| new_entity(item, klass) }

  EntityList.new(entity_type, resource_version, collection)
end