Class: DTK::State::ExecutableAction

Inherits:
Object
  • Object
show all
Defined in:
lib/state/executable_action.rb,
lib/state/executable_action/attribute_type_info.rb

Defined Under Namespace

Classes: AttributeTypeInfo

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ ExecutableAction

Returns a new instance of ExecutableAction.



7
8
9
10
11
12
13
# File 'lib/state/executable_action.rb', line 7

def initialize(params)
  @name = params[:name]
  @entrypoint = params[:entrypoint]
  @type = params[:type]
  @bash_script = params[:bash_script]
  @attribute_type_info = AttributeTypeInfo.create_from_kube_hash(params[:attributes] || {})
end

Instance Attribute Details

#attribute_type_infoObject (readonly)

Returns the value of attribute attribute_type_info.



5
6
7
# File 'lib/state/executable_action.rb', line 5

def attribute_type_info
  @attribute_type_info
end

#bash_scriptObject (readonly)

Returns the value of attribute bash_script.



5
6
7
# File 'lib/state/executable_action.rb', line 5

def bash_script
  @bash_script
end

#entrypointObject (readonly)

Returns the value of attribute entrypoint.



5
6
7
# File 'lib/state/executable_action.rb', line 5

def entrypoint
  @entrypoint
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/state/executable_action.rb', line 5

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



5
6
7
# File 'lib/state/executable_action.rb', line 5

def type
  @type
end

Class Method Details

.get(crd_assembly_namespace, crd_assembly_name, component_name, action_name, opts = {}) ⇒ Object

Raises:

  • (Error)


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/state/executable_action.rb', line 15

def self.get(crd_assembly_namespace, crd_assembly_name, component_name, action_name, opts = {})
  component_obj = Component.get(crd_assembly_namespace, crd_assembly_name, component_name, opts)
  actions = component_obj.component_def.executable_actions
  action  = actions[action_name]

  raise Error.new("Unable to find action '#{action_name}'") unless action

  ExecutableAction.new(
    {
      name: action_name,
      entrypoint: action[:entrypoint] || '',
      type: action[:type] || '',
      bash_script: action[:bash_script] || '',
      attributes: action[:attributes] || {}
    }
  )
end