hako 0.3.1 → 0.4.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: 0982aa9c0d21c4c9d1455261f9217208900b3ac3
4
- data.tar.gz: d6f4cf41df7fd6e3813d45c05e3fd2ee27761a34
3
+ metadata.gz: 7051366d540062e8a8d89a5e4a29d4fd439e53f9
4
+ data.tar.gz: de094d094bcc3773b789b3f4fbe12a24a9f64752
5
5
  SHA512:
6
- metadata.gz: e4e791d18be1cdc58e21d6c45982300cdf6d1fd23576486267644c16526c1427f146c4f73eb0ff1b9e3e99fb998663bad7f7dfa07fc76394c39cdcbcd47c1d44
7
- data.tar.gz: 0061c7fa160d2a24f86fe4cfd11bb558c9ddfcbc2c6241a80a35f8830523b86da33215063a1d556fa3e5144400d2e8f2c283f3357a1ed917663dfdd872e8c772
6
+ metadata.gz: 41d1331497077ed082ef86164f37b255a9a644444242ef208fb12e4a0301e3934ba63f2d7ec4e90587d286e2c600c46fc13c76b5665260aed3fc77cf367b6b2c
7
+ data.tar.gz: 812835ac65a95d396687eb2a8314d736e5351099669374f5765ecd9b1688451b9325cf4dc99f0308d4a8062271bbaa9749dc3080e39c27b2641667918d16c5f5
@@ -26,9 +26,10 @@ module Hako
26
26
  )
27
27
  scripts = @app.yaml.fetch('scripts', []).map { |config| load_script(config) }
28
28
 
29
- scripts.each { |script| script.before_deploy(app) }
30
- scheduler.deploy(app, env, app_port, front, force: force)
31
- scripts.each { |script| script.after_deploy(app) }
29
+ containers = { 'app' => app, 'front' => front }
30
+ scripts.each { |script| script.before_deploy(containers) }
31
+ scheduler.deploy(containers, env, app_port, force: force)
32
+ scripts.each { |script| script.after_deploy(containers) }
32
33
  end
33
34
 
34
35
  def oneshot(commands, tag: 'latest')
@@ -1,7 +1,11 @@
1
1
  module Hako
2
2
  class Container
3
+ DEFAULT_CONFIG = {
4
+ 'docker_labels' => {},
5
+ }.freeze
6
+
3
7
  def initialize(definition)
4
- @definition = definition
8
+ @definition = definition.merge(DEFAULT_CONFIG)
5
9
  end
6
10
 
7
11
  %w[
@@ -1,7 +1,8 @@
1
1
  require 'erb'
2
+ require 'hako/container'
2
3
 
3
4
  module Hako
4
- FrontConfig = Struct.new(:type, :image_tag, :s3, :extra)
5
+ FrontConfig = Struct.new(:type, :container, :s3, :extra)
5
6
  class FrontConfig
6
7
  S3Config = Struct.new(:region, :bucket, :prefix) do
7
8
  def initialize(options)
@@ -21,7 +22,9 @@ module Hako
21
22
 
22
23
  def initialize(options)
23
24
  self.type = options.fetch('type')
24
- self.image_tag = options.fetch('image_tag')
25
+ self.container = Container.new(
26
+ 'image_tag' => options.fetch('image_tag'),
27
+ )
25
28
  self.s3 = S3Config.new(options.fetch('s3'))
26
29
  self.extra = options.fetch('extra', {})
27
30
  end
@@ -8,7 +8,7 @@ module Hako
8
8
  def initialize(_app_id, _options)
9
9
  end
10
10
 
11
- def deploy(_app, _env, _app_port, _front_config, _options)
11
+ def deploy(_containers, _env, _app_port, _options)
12
12
  raise NotImplementedError
13
13
  end
14
14
 
@@ -7,8 +7,8 @@ module Hako
7
7
  @app_id = app_id
8
8
  end
9
9
 
10
- def deploy(app, env, app_port, _front, force: false)
11
- puts "Deploy #{app.image_tag} with app_port=#{app_port}, force=#{force}"
10
+ def deploy(containers, env, app_port, force: false)
11
+ puts "Deploy #{containers.fetch('app').image_tag} with app_port=#{app_port}, force=#{force}"
12
12
  puts 'Environment variables:'
13
13
  env.each do |key, val|
14
14
  puts " #{key}=#{val.inspect}"
@@ -23,8 +23,10 @@ module Hako
23
23
  @ec2 = Aws::EC2::Client.new(region: region)
24
24
  end
25
25
 
26
- def deploy(app, env, app_port, front, force: false)
26
+ def deploy(containers, env, app_port, force: false)
27
27
  @force_mode = force
28
+ app = containers.fetch('app')
29
+ front = containers.fetch('front')
28
30
  front_env = {
29
31
  'AWS_DEFAULT_REGION' => front.config.s3.region,
30
32
  'S3_CONFIG_BUCKET' => front.config.s3.bucket,
@@ -229,13 +231,14 @@ module Hako
229
231
  environment = env.map { |k, v| { name: k, value: v } }
230
232
  {
231
233
  name: 'front',
232
- image: front_config.image_tag,
234
+ image: front_config.container.image_tag,
233
235
  cpu: 100,
234
236
  memory: 100,
235
237
  links: ['app:app'],
236
238
  port_mappings: [{ container_port: 80, host_port: front_port, protocol: 'tcp' }],
237
239
  essential: true,
238
240
  environment: environment,
241
+ docker_labels: front_config.container.docker_labels,
239
242
  }
240
243
  end
241
244
 
@@ -1,3 +1,3 @@
1
1
  module Hako
2
- VERSION = '0.3.1'.freeze
2
+ VERSION = '0.4.0'.freeze
3
3
  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.3.1
4
+ version: 0.4.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-02-16 00:00:00.000000000 Z
11
+ date: 2016-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk