hako 0.10.0 → 0.11.0

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: 790a66a0b27267656b3f0b5b39a81fa2b54ee772
4
- data.tar.gz: 08bdb98df7dda625874ecb89a0d2b1d2dec14da6
3
+ metadata.gz: d38174e02789d9c6483172755239f8533b8be58a
4
+ data.tar.gz: 412c52142395ca4e316bea3149d8e643de6f9802
5
5
  SHA512:
6
- metadata.gz: cf57c0ce8f75f05fc37709da163324b520dc36912aeb9e6065a218f64311309255512455eae6ac0891c1fe1d428e00c251a14468ea2f0498d303a35abfff3549
7
- data.tar.gz: e2bf166333f4cda8fe99f5ea22d51a88131991278b6191e4b5ed3e14217559dd5e15b424783212fb91ce3342e7f726a7726ddccaad66d7fa4c6a0ba2a186ce64
6
+ metadata.gz: 14a30482ccd6a222fb278191ef74269491f7846d0151e82e9083451e8a87c8a73c5791f35472cebc2787ce66279aa018fcbab6667c0f4a8a4f89e7a82d2e6504
7
+ data.tar.gz: 3cac7854f49ef7989b284f14c5c1cdc96e1181cd2e003419f2557886ec96021b0e002d404b78d38d2511c00a8c52592cc30b5009c8db5d4aec2c730101d90453
data/.rubocop_todo.yml CHANGED
@@ -13,6 +13,9 @@ Metrics/LineLength:
13
13
  Metrics/MethodLength:
14
14
  Enabled: false
15
15
 
16
+ Metrics/ParameterLists:
17
+ Enabled: false
18
+
16
19
  Metrics/PerceivedComplexity:
17
20
  Enabled: false
18
21
 
data/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  Deploy Docker container.
6
6
 
7
7
  ## Status
8
- Under development
8
+ Under development. Any incompatible change will happen without notice.
9
9
 
10
10
  ## Installation
11
11
 
@@ -15,7 +15,8 @@ module Hako
15
15
  def deploy(force: false, tag: 'latest', dry_run: false)
16
16
  containers = load_containers(tag, dry_run: dry_run)
17
17
  scripts = @app.yaml.fetch('scripts', []).map { |config| load_script(config, dry_run: dry_run) }
18
- scheduler = load_scheduler(@app.yaml['scheduler'], scripts, force: force, dry_run: dry_run)
18
+ volumes = @app.yaml.fetch('volumes', [])
19
+ scheduler = load_scheduler(@app.yaml['scheduler'], scripts, volumes: volumes, force: force, dry_run: dry_run)
19
20
 
20
21
  scripts.each { |script| script.before_deploy(containers) }
21
22
  scheduler.deploy(containers)
@@ -25,7 +26,8 @@ module Hako
25
26
  def oneshot(commands, tag:, containers:, env: {}, dry_run: false)
26
27
  containers = load_containers(tag, dry_run: dry_run, with: containers)
27
28
  scripts = @app.yaml.fetch('scripts', []).map { |config| load_script(config, dry_run: dry_run) }
28
- scheduler = load_scheduler(@app.yaml['scheduler'], scripts, dry_run: dry_run)
29
+ volumes = @app.yaml.fetch('volumes', [])
30
+ scheduler = load_scheduler(@app.yaml['scheduler'], scripts, volumes: volumes, dry_run: dry_run)
29
31
 
30
32
  exit_code = with_oneshot_signal_handlers(scheduler) do
31
33
  scheduler.oneshot(containers, commands, env)
@@ -77,8 +79,8 @@ module Hako
77
79
  DefinitionLoader.new(@app, dry_run: dry_run).load(tag, with: with)
78
80
  end
79
81
 
80
- def load_scheduler(yaml, scripts, force: false, dry_run: false)
81
- Loader.new(Hako::Schedulers, 'hako/schedulers').load(yaml.fetch('type')).new(@app.id, yaml, scripts: scripts, force: force, dry_run: dry_run)
82
+ def load_scheduler(yaml, scripts, volumes: [], force: false, dry_run: false)
83
+ Loader.new(Hako::Schedulers, 'hako/schedulers').load(yaml.fetch('type')).new(@app.id, yaml, volumes: volumes, scripts: scripts, force: force, dry_run: dry_run)
82
84
  end
83
85
 
84
86
  def load_script(yaml, dry_run:)
@@ -18,6 +18,7 @@ module Hako
18
18
  cpu
19
19
  memory
20
20
  links
21
+ mount_points
21
22
  ].each do |name|
22
23
  define_method(name) do
23
24
  @definition[name]
@@ -57,6 +58,7 @@ module Hako
57
58
  {
58
59
  'docker_labels' => {},
59
60
  'links' => [],
61
+ 'mount_points' => [],
60
62
  }
61
63
  end
62
64
 
@@ -6,8 +6,9 @@ module Hako
6
6
  class ValidationError < Error
7
7
  end
8
8
 
9
- def initialize(app_id, options, scripts:, dry_run:, force:)
9
+ def initialize(app_id, options, volumes:, scripts:, dry_run:, force:)
10
10
  @app_id = app_id
11
+ @volumes = volumes
11
12
  @scripts = scripts
12
13
  @dry_run = dry_run
13
14
  @force = force
@@ -226,6 +226,10 @@ module Hako
226
226
  task_definition.container_definitions.each do |c|
227
227
  container_definitions[c.name] = c
228
228
  end
229
+
230
+ if different_volumes?(task_definition.volumes)
231
+ return true
232
+ end
229
233
  if definitions.any? { |definition| different_definition?(definition, container_definitions.delete(definition[:name])) }
230
234
  return true
231
235
  end
@@ -235,6 +239,23 @@ module Hako
235
239
  true
236
240
  end
237
241
 
242
+ def different_volumes?(actual_volumes)
243
+ if @volumes.size != actual_volumes.size
244
+ return true
245
+ end
246
+ actual_volumes.each do |actual_volume|
247
+ expected_volume = @volumes[actual_volume.name]
248
+ if expected_volume.nil?
249
+ return true
250
+ end
251
+ if expected_volume['source_path'] != actual_volume.host.source_path
252
+ return true
253
+ end
254
+ end
255
+
256
+ false
257
+ end
258
+
238
259
  def different_definition?(expected_container, actual_container)
239
260
  EcsDefinitionComparator.new(expected_container).different?(actual_container)
240
261
  end
@@ -244,6 +265,7 @@ module Hako
244
265
  @ecs.register_task_definition(
245
266
  family: @app_id,
246
267
  container_definitions: definitions,
268
+ volumes: volumes_definition,
247
269
  ).task_definition
248
270
  else
249
271
  :noop
@@ -267,12 +289,22 @@ module Hako
267
289
  @ecs.register_task_definition(
268
290
  family: "#{@app_id}-oneshot",
269
291
  container_definitions: definitions,
292
+ volumes: volumes_definition,
270
293
  ).task_definition
271
294
  else
272
295
  :noop
273
296
  end
274
297
  end
275
298
 
299
+ def volumes_definition
300
+ @volumes.map do |name, volume|
301
+ {
302
+ name: name,
303
+ host: { source_path: volume['source_path'] },
304
+ }
305
+ end
306
+ end
307
+
276
308
  def front_container(front, front_port)
277
309
  environment = front.env.map { |k, v| { name: k, value: v } }
278
310
  {
@@ -285,6 +317,7 @@ module Hako
285
317
  essential: true,
286
318
  environment: environment,
287
319
  docker_labels: front.docker_labels,
320
+ mount_points: front.mount_points,
288
321
  }
289
322
  end
290
323
 
@@ -300,6 +333,7 @@ module Hako
300
333
  essential: true,
301
334
  environment: environment,
302
335
  docker_labels: app.docker_labels,
336
+ mount_points: app.mount_points,
303
337
  }
304
338
  end
305
339
 
@@ -6,7 +6,7 @@ module Hako
6
6
  @expected_container = expected_container
7
7
  end
8
8
 
9
- CONTAINER_KEYS = %i[image cpu memory links docker_labels].freeze
9
+ CONTAINER_KEYS = %i[image cpu memory links docker_labels mount_points].freeze
10
10
  PORT_MAPPING_KEYS = %i[container_port host_port protocol].freeze
11
11
  ENVIRONMENT_KEYS = %i[name value].freeze
12
12
 
data/lib/hako/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Hako
3
- VERSION = '0.10.0'
3
+ VERSION = '0.11.0'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hako
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kohei Suzuki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-14 00:00:00.000000000 Z
11
+ date: 2016-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk