Class: Wrapbox::Configuration

Inherits:
Struct
  • Object
show all
Defined in:
lib/wrapbox/configuration.rb

Constant Summary collapse

AVAILABLE_RUNNERS =
%i(docker ecs)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Configuration

Returns a new instance of Configuration.



62
63
64
# File 'lib/wrapbox/configuration.rb', line 62

def initialize(*args)
  super
end

Instance Attribute Details

#additional_container_definitionsObject

Returns the value of attribute additional_container_definitions

Returns:

  • (Object)

    the current value of additional_container_definitions



5
6
7
# File 'lib/wrapbox/configuration.rb', line 5

def additional_container_definitions
  @additional_container_definitions
end

#clusterObject

Returns the value of attribute cluster

Returns:

  • (Object)

    the current value of cluster



5
6
7
# File 'lib/wrapbox/configuration.rb', line 5

def cluster
  @cluster
end

#container_definitionObject

Returns the value of attribute container_definition

Returns:

  • (Object)

    the current value of container_definition



5
6
7
# File 'lib/wrapbox/configuration.rb', line 5

def container_definition
  @container_definition
end

#container_definitionsObject

Returns the value of attribute container_definitions

Returns:

  • (Object)

    the current value of container_definitions



5
6
7
# File 'lib/wrapbox/configuration.rb', line 5

def container_definitions
  @container_definitions
end

#cpuObject

Returns the value of attribute cpu

Returns:

  • (Object)

    the current value of cpu



5
6
7
# File 'lib/wrapbox/configuration.rb', line 5

def cpu
  @cpu
end

#keep_containerObject

Returns the value of attribute keep_container

Returns:

  • (Object)

    the current value of keep_container



5
6
7
# File 'lib/wrapbox/configuration.rb', line 5

def keep_container
  @keep_container
end

#launch_typeObject

Returns the value of attribute launch_type

Returns:

  • (Object)

    the current value of launch_type



5
6
7
# File 'lib/wrapbox/configuration.rb', line 5

def launch_type
  @launch_type
end

#log_fetcherObject

Returns the value of attribute log_fetcher

Returns:

  • (Object)

    the current value of log_fetcher



5
6
7
# File 'lib/wrapbox/configuration.rb', line 5

def log_fetcher
  @log_fetcher
end

#memoryObject

Returns the value of attribute memory

Returns:

  • (Object)

    the current value of memory



5
6
7
# File 'lib/wrapbox/configuration.rb', line 5

def memory
  @memory
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



5
6
7
# File 'lib/wrapbox/configuration.rb', line 5

def name
  @name
end

#network_configurationObject

Returns the value of attribute network_configuration

Returns:

  • (Object)

    the current value of network_configuration



5
6
7
# File 'lib/wrapbox/configuration.rb', line 5

def network_configuration
  @network_configuration
end

#network_modeObject

Returns the value of attribute network_mode

Returns:

  • (Object)

    the current value of network_mode



5
6
7
# File 'lib/wrapbox/configuration.rb', line 5

def network_mode
  @network_mode
end

#placement_constraintsObject

Returns the value of attribute placement_constraints

Returns:

  • (Object)

    the current value of placement_constraints



5
6
7
# File 'lib/wrapbox/configuration.rb', line 5

def placement_constraints
  @placement_constraints
end

#placement_strategyObject

Returns the value of attribute placement_strategy

Returns:

  • (Object)

    the current value of placement_strategy



5
6
7
# File 'lib/wrapbox/configuration.rb', line 5

def placement_strategy
  @placement_strategy
end

#regionObject

Returns the value of attribute region

Returns:

  • (Object)

    the current value of region



5
6
7
# File 'lib/wrapbox/configuration.rb', line 5

def region
  @region
end

#requires_compatibilitiesObject

Returns the value of attribute requires_compatibilities

Returns:

  • (Object)

    the current value of requires_compatibilities



5
6
7
# File 'lib/wrapbox/configuration.rb', line 5

def requires_compatibilities
  @requires_compatibilities
end

#retryObject

Returns the value of attribute retry

Returns:

  • (Object)

    the current value of retry



5
6
7
# File 'lib/wrapbox/configuration.rb', line 5

def retry
  @retry
end

#retry_intervalObject

Returns the value of attribute retry_interval

Returns:

  • (Object)

    the current value of retry_interval



5
6
7
# File 'lib/wrapbox/configuration.rb', line 5

def retry_interval
  @retry_interval
end

#retry_interval_multiplierObject

Returns the value of attribute retry_interval_multiplier

Returns:

  • (Object)

    the current value of retry_interval_multiplier



5
6
7
# File 'lib/wrapbox/configuration.rb', line 5

def retry_interval_multiplier
  @retry_interval_multiplier
end

#revisionObject

Returns the value of attribute revision

Returns:

  • (Object)

    the current value of revision



5
6
7
# File 'lib/wrapbox/configuration.rb', line 5

def revision
  @revision
end

#runnerObject

Returns the value of attribute runner

Returns:

  • (Object)

    the current value of runner



5
6
7
# File 'lib/wrapbox/configuration.rb', line 5

def runner
  @runner
end

#task_definitionObject

Returns the value of attribute task_definition

Returns:

  • (Object)

    the current value of task_definition



5
6
7
# File 'lib/wrapbox/configuration.rb', line 5

def task_definition
  @task_definition
end

#task_role_arnObject

Returns the value of attribute task_role_arn

Returns:

  • (Object)

    the current value of task_role_arn



5
6
7
# File 'lib/wrapbox/configuration.rb', line 5

def task_role_arn
  @task_role_arn
end

#volumesObject

Returns the value of attribute volumes

Returns:

  • (Object)

    the current value of volumes



5
6
7
# File 'lib/wrapbox/configuration.rb', line 5

def volumes
  @volumes
end

Class Method Details

.load_config(config) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/wrapbox/configuration.rb', line 31

def self.load_config(config)
  new(
    config["name"],
    config["revision"],
    config["runner"] ? config["runner"].to_sym : :docker,
    config["cluster"],
    config["region"],
    config["retry"] || 0,
    config["retry_interval"] || 1,
    config["retry_interval_multiplier"] || 2,
    config["container_definition"]&.deep_symbolize_keys,
    config["container_definitions"]&.map(&:deep_symbolize_keys) || [],
    config["volumes"]&.map(&:deep_symbolize_keys) || [],
    config["placement_constraints"]&.map(&:deep_symbolize_keys) || [],
    config["placement_strategy"]&.map(&:deep_symbolize_keys) || [],
    config["launch_type"],
    config["requires_compatibilities"] || ["EC2"],
    config["task_definition"]&.deep_symbolize_keys,
    config["additional_container_definitions"]&.map(&:deep_symbolize_keys) || [],
    config["network_mode"],
    config["network_configuration"]&.deep_symbolize_keys,
    config["cpu"]&.to_s,
    config["memory"]&.to_s,
    config["task_role_arn"],
    config["keep_container"],
    config["log_fetcher"]&.deep_symbolize_keys
  )
end

Instance Method Details

#build_runner(overrided_runner = nil) ⇒ Object



66
67
68
69
70
71
# File 'lib/wrapbox/configuration.rb', line 66

def build_runner(overrided_runner = nil)
  r = overrided_runner || runner
  raise "#{r} is unsupported runner" unless AVAILABLE_RUNNERS.include?(r.to_sym)
  require "wrapbox/runner/#{r}"
  Wrapbox::Runner.const_get(r.to_s.camelcase).new(to_h)
end

#run(class_name, method_name, args, **options) ⇒ Object



73
74
75
# File 'lib/wrapbox/configuration.rb', line 73

def run(class_name, method_name, args, **options)
  build_runner.run(class_name, method_name, args, **options)
end

#run_cmd(*cmd, **options) ⇒ Object



77
78
79
# File 'lib/wrapbox/configuration.rb', line 77

def run_cmd(*cmd, **options)
  build_runner.run_cmd(*cmd, **options)
end