class DTK::CrdParser::ComponentDef
Constants
- MODE_DEFAULT
Attributes
attribute_type_info[R]
executable_actions[R]
name[R]
namespace[R]
resource_version[R]
Public Class Methods
create_from_kube(client, component_instance, component_def_name)
click to toggle source
# File lib/crd_parser/component_def.rb, line 18 def self.create_from_kube(client, component_instance, component_def_name) destructured_component = BaseClass::Helper::ClassAndInstanceMixin.destructureActionComponent(component_def_name) module_ref = resolveModuleReference(component_instance[:references][:module_refs], component_def_name, destructured_component[:moduleName]) componentDef = client.get_componentdef("#{destructured_component[:moduleName]}-#{destructured_component[:componentName]}", module_ref[:namespace]) componentMetadata = self.metadata(componentDef) name = componentMetadata[:name] namespace = componentMetadata[:namespace] resourceVersion = componentMetadata[:resourceVersion] componentDefSpec = componentDef[:spec] || {} componentDefAction = componentDefSpec[:actions] componentDefAttributes = [] (componentDefSpec[:attributes] || []).each do |attribute| componentDefAttributes.push AttributeTypeInfo.resolveAttr(attribute) end metadata = { name: name, namespace: namespace, resourceVersion: resourceVersion } ComponentDef.new(metadata, componentDefAction, componentDefAttributes) end
new(metadata, componentDefActions, componentDefAttributes)
click to toggle source
# File lib/crd_parser/component_def.rb, line 9 def initialize(metadata, componentDefActions, componentDefAttributes) @name = fail_if_nil(metadata[:name], 'metadata[:name]') @namespace = fail_if_nil(metadata[:namespace], 'metadata[:namespace]') @resource_version = fail_if_nil(metadata[:resourceVersion], 'metadata[:resourceVersion]') @executable_actions = componentDefActions || [] @attribute_type_info = componentDefAttributes || [] end
Protected Class Methods
metadata(componentDef)
click to toggle source
# File lib/crd_parser/component_def.rb, line 63 def self.metadata(componentDef) componentDef[:metadata] end
Private Class Methods
isOnSpecificNode(actionComponent)
click to toggle source
# File lib/crd_parser/component_def.rb, line 58 def self.isOnSpecificNode(actionComponent) actionComponent.include? "/" end
resolveModuleReference(module_refs, component_full_name, module_name)
click to toggle source
# File lib/crd_parser/component_def.rb, line 48 def self.resolveModuleReference(module_refs, component_full_name, module_name) raise "There are no module refs for component #{component_full_name} in component instance." if module_refs.nil? module_ref = module_refs.find { |module_ref| module_ref[:name] == module_name } if(module_ref.nil?) raise "Could not resolve module reference for component #{component_full_name} in component instance. Expected to find: #{module_name}" end module_ref end