Class: EcsDeployer::Task::Client
- Inherits:
-
Object
- Object
- EcsDeployer::Task::Client
- Defined in:
- lib/ecs_deployer/task/client.rb
Instance Method Summary collapse
- #initialize(aws_options = {}) ⇒ EcsDeployer::Task::Client constructor
- #register(path, replace_variables = {}) ⇒ Aws::ECS::Types::TaskDefinition
- #register_clone(cluster, service) ⇒ String
- #register_hash(task_definition, replace_variables = {}) ⇒ Aws::ECS::Types::TaskDefinition
Constructor Details
#initialize(aws_options = {}) ⇒ EcsDeployer::Task::Client
10 11 12 13 |
# File 'lib/ecs_deployer/task/client.rb', line 10 def initialize( = {}) @ecs = Aws::ECS::Client.new() @cipher = EcsDeployer::Util::Cipher.new() end |
Instance Method Details
#register(path, replace_variables = {}) ⇒ Aws::ECS::Types::TaskDefinition
18 19 20 21 22 |
# File 'lib/ecs_deployer/task/client.rb', line 18 def register(path, replace_variables = {}) raise IOError, "File does not exist. [#{path}]" unless File.exist?(path) register_hash(YAML.load(File.read(path)), replace_variables) end |
#register_clone(cluster, service) ⇒ String
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/ecs_deployer/task/client.rb', line 40 def register_clone(cluster, service) result = @ecs.describe_services( cluster: cluster, services: [service] ) result[:services].each do |svc| next unless svc[:service_name] == service result = @ecs.describe_task_definition( task_definition: svc[:task_definition] ) task_definition = result[:task_definition].to_hash delete_keys = [:task_definition_arn, :revision, :status, :requires_attributes, :compatibilities] delete_keys.each do |delete_key| task_definition.delete(delete_key) end return register_hash(task_definition) end raise ServiceNotFoundError, "'#{service}' service is not found." end |
#register_hash(task_definition, replace_variables = {}) ⇒ Aws::ECS::Types::TaskDefinition
27 28 29 30 31 32 33 34 35 |
# File 'lib/ecs_deployer/task/client.rb', line 27 def register_hash(task_definition, replace_variables = {}) task_definition = Oj.load(Oj.dump(task_definition), symbol_keys: true) replace_parameter_variables!(task_definition, replace_variables) decrypt_environment_variables!(task_definition) result = @ecs.register_task_definition(task_definition) result[:task_definition] end |