ecs_deployer 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 12a1a6119ccbfa559a988d6a7ccbc3804c8a746d
4
- data.tar.gz: 6676d951da1365975628e81125c4d22437409094
3
+ metadata.gz: 766a0d93cdf1477bf6ffb712a215f11c760eb4e9
4
+ data.tar.gz: dc0faa2dc4f507e278ea14483ceba4e1580ab767
5
5
  SHA512:
6
- metadata.gz: cc408464570b09cb10cc4a4be000212be87c6b121d62498566d751ae8104f26f24f1d9468a1ec5e5fe50dd14a637f17b14dacf2cdf8e0908727c23c993163af1
7
- data.tar.gz: e8ab53a763ea7aba4e88419dbebaee9cce021f027f3200d2e64310f9dc7418288110378989eb81568d9e468d95912cc10e67ce5b0ae2ed26ad78cd69eaebd4e7
6
+ metadata.gz: 4c183066a8a94005bf1ee9cc687a328a91c07ee16f34749565cff92932abb13099ddf95682b15ffb280dfcb51a34055c00570e882b49e45df0b4d5d827cd8ccb
7
+ data.tar.gz: e862a11e30b72b8b8bce1c92c40a93c3e1882afe9f8033da25294c5faeaf96ec510256bab2a906180aa56135918da7fe6bf525d127a2bd94d908215327a317f6
data/README.md CHANGED
@@ -19,13 +19,13 @@ gem 'ecs_deployer'
19
19
 
20
20
  And then execute:
21
21
 
22
- ```
22
+ ```ruby
23
23
  $ bundle
24
24
  ```
25
25
 
26
26
  Or install it yourself as:
27
27
 
28
- ```
28
+ ```ruby
29
29
  $ gem install ecs_deployer
30
30
  ```
31
31
 
@@ -34,7 +34,7 @@ $ gem install ecs_deployer
34
34
  Write task definition in YAML format.
35
35
  For available parameters see [Task Definition Parameters](http://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html).
36
36
 
37
- ```
37
+ ```yaml
38
38
  container_definitions:
39
39
  - name: wordpress
40
40
  links:
@@ -62,7 +62,7 @@ family: hello_world
62
62
  `environment` parameter supports KMS encrypted values.
63
63
  Encrypted values must be enclosed in `${XXX}`.
64
64
 
65
- ```
65
+ ```yaml
66
66
  - environment:
67
67
  - name: MYSQL_ROOT_PASSWORD
68
68
  value: ${fiSAIfIFxd...}
@@ -76,36 +76,48 @@ Values are decrypted when task is created.
76
76
 
77
77
  This sample file is in `spec/fixtures/task.yml`.
78
78
 
79
- ```
79
+ ```ruby
80
80
  deployer = EcsDeployer::Client.new
81
81
  deployer.register_task('development.yml')
82
82
  deployer.update_service('cluster', 'development')
83
83
  ```
84
84
 
85
+ `{{xxx}}` parameter is construed variable.
86
+
87
+ ```yaml
88
+ container_definitions:
89
+ - name: wordpress
90
+ image: wordpress:{{tag}}
91
+ ```
92
+
93
+ ```ruby
94
+ deployer.register_task('development.yml', tag: 'latest')
95
+ ```
96
+
85
97
  ### CLI
86
98
 
87
99
  #### Register new task
88
100
 
89
- ```
101
+ ```ruby
90
102
  $ bundle exec ecs_deployer task-register --path=example/fixtures/task.yml
91
103
  ```
92
104
 
93
105
  #### Encrypt environment value
94
106
 
95
- ```
107
+ ```ruby
96
108
  $ bundle exec ecs_deployer encrypt --master-key=master --value='test'
97
109
  Encrypted value: ${xxx}
98
110
  ```
99
111
 
100
112
  #### Decrypt environment value
101
113
 
102
- ```
114
+ ```ruby
103
115
  $ bundle exec ecs_deployer decrypt --value='${xxx}'
104
116
  Decrypted value: xxx
105
117
  ```
106
118
 
107
119
  #### Update service
108
120
 
109
- ```
121
+ ```ruby
110
122
  $ bundle exec ecs_deployer update-service --cluster=xxx --service=xxx --wait --timeout=600
111
123
  ```
@@ -4,5 +4,5 @@ require 'ecs_deployer'
4
4
  path = File.expand_path('../spec/fixtures/task.yml', File.dirname(File.realpath(__FILE__)))
5
5
 
6
6
  deployer = EcsDeployer::Client.new
7
- deployer.register_task(path)
7
+ deployer.register_task(path, tag: 'latest')
8
8
  # deployer.update_service('sandbox', 'production')
@@ -24,9 +24,10 @@ module EcsDeployer
24
24
 
25
25
  desc 'task_register', 'Create new task definition'
26
26
  option :path, required: true
27
+ option :replace_variables, type: :hash, default: {}
27
28
  def task_register
28
29
  path = File.expand_path(options[:path], Dir.pwd)
29
- result = @deployer.register_task(path)
30
+ result = @deployer.register_task(path, options[:replace_variables])
30
31
 
31
32
  puts "Registered task: #{result}"
32
33
  end
@@ -54,7 +55,7 @@ module EcsDeployer
54
55
  puts "Encrypted value: #{@deployer.encrypt(options[:master_key], options[:value])}"
55
56
  end
56
57
 
57
- desc 'encrypt', 'Decrypt value of argument with KMS.'
58
+ desc 'decrypt', 'Decrypt value of argument with KMS.'
58
59
  option :value, required: true
59
60
  def decrypt
60
61
  puts "Decrypted value: #{@deployer.decrypt(options[:value])}"
@@ -47,17 +47,21 @@ module EcsDeployer
47
47
  end
48
48
 
49
49
  # @param [String] path
50
+ # @param [Hash] params
50
51
  # @return [String]
51
- def register_task(path)
52
+ def register_task(path, params = {})
52
53
  raise IOError, "File does not exist. [#{path}]" unless File.exist?(path)
53
54
 
54
- register_task_hash(YAML.load(File.read(path)))
55
+ register_task_hash(YAML.load(File.read(path)), params)
55
56
  end
56
57
 
57
58
  # @param [Hash] task_definition
59
+ # @param [Hash] params
58
60
  # @return [String]
59
- def register_task_hash(task_definition)
61
+ def register_task_hash(task_definition, replace_variables = {})
60
62
  task_definition = Oj.load(Oj.dump(task_definition), symbol_keys: true)
63
+
64
+ replace_parameter_variables!(task_definition, replace_variables)
61
65
  decrypt_environment_variables!(task_definition)
62
66
 
63
67
  result = @cli.register_task_definition(
@@ -115,6 +119,20 @@ module EcsDeployer
115
119
 
116
120
  private
117
121
 
122
+ # @param [Array, Hash] variables
123
+ # @param [Hash] replace_variables
124
+ def replace_parameter_variables!(variables, replace_variables = {})
125
+ for variable in variables do
126
+ if variable.class == Array || variable.class == Hash
127
+ replace_parameter_variables!(variable, replace_variables)
128
+ elsif variable.class == String
129
+ replace_variables.each do |replace_key, replace_value|
130
+ variable.gsub!("{{#{replace_key}}}", replace_value)
131
+ end
132
+ end
133
+ end
134
+ end
135
+
118
136
  # @param [Hash] task_definition
119
137
  def decrypt_environment_variables!(task_definition)
120
138
  raise TaskDefinitionValidateError, '\'container_definition\' is undefined.' unless task_definition.key?(:container_definitions)
@@ -1,3 +1,3 @@
1
1
  module EcsDeployer
2
- VERSION = '1.0.1'.freeze
2
+ VERSION = '1.0.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecs_deployer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - naomichi-y
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-25 00:00:00.000000000 Z
11
+ date: 2017-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: runtime_command
@@ -222,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
222
222
  version: '0'
223
223
  requirements: []
224
224
  rubyforge_project:
225
- rubygems_version: 2.5.1
225
+ rubygems_version: 2.6.10
226
226
  signing_key:
227
227
  specification_version: 4
228
228
  summary: Deploy application to ECS.