class DTK::CrdParser::Component
Constants
- MODE_DEFAULT
Attributes
attributes[R]
component_def[R]
name[R]
Public Class Methods
create_from_kube(client, component_instance, component_name)
click to toggle source
# File lib/crd_parser/component.rb, line 17 def self.create_from_kube(client, component_instance, component_name) component_instance_obj = client.get_component(component_instance[:name], component_instance[:namespace]) component_def = ComponentDef.create_from_kube(client, component_instance_obj, component_name) component_attributes = getComponentAttributes(component_name, component_instance_obj[:spec][:components]) attribute_name_value = BaseClass::Helper::ClassAndInstanceMixin.destructureActionComponent(component_name)[:attributeName] attributes = [] attributes.push(Attribute.create_from_kube("name", attribute_name_value, {})) if component_attributes (component_attributes.to_hash || []).each do |attribute_name, attribute_value| attribute_type_info = (component_def.attribute_type_info .select {|attribute| attribute.name == attribute_name.to_s} || []).first encrypted = attribute_type_info.encrypted if attribute_type_info attributes.push Attribute.create_from_kube(attribute_name, attribute_value, {encrypted: encrypted || false}) end end #set all attributes, not just ones with values other_attrs = component_def.attribute_type_info.select {|attribute| attributes.find{|h| h.name.to_s == attribute.name.to_s }.nil?} other_attrs.each do |attribute| attributes.push Attribute.create_from_kube(attribute.name, nil, {encrypted: attribute.encrypted || false}) end Component.new(component_name, component_def, attributes) end
new(name, component_def, attributes)
click to toggle source
# File lib/crd_parser/component.rb, line 11 def initialize(name, component_def, attributes) @name = fail_if_nil(name, 'name') @component_def = fail_if_nil(component_def, 'component_def') # this wil point to the corresponding component def @attributes = attributes || [] # array that has an Attribute object for each attribute; these are name-value pairs end
Protected Class Methods
getComponentAttributes(fullComponentName, components)
click to toggle source
# File lib/crd_parser/component.rb, line 43 def self.getComponentAttributes(fullComponentName, components) component = components.each do |component| componentObj = component[fullComponentName] if(componentObj && componentObj.is_a?(Kubeclient::Resource)) return componentObj[:attributes] end end return nil end