hako 0.5.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/examples/hello-lb.yml +4 -4
- data/examples/hello.yml +11 -4
- data/lib/hako/commander.rb +4 -0
- data/lib/hako/container.rb +3 -1
- data/lib/hako/front.rb +6 -0
- data/lib/hako/schedulers/ecs.rb +20 -11
- data/lib/hako/version.rb +1 -1
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 1e64f878fa8086ac6bbf25618270783b624a0c3d
         | 
| 4 | 
            +
              data.tar.gz: 3bd05c5d3570b3df3683bf96089ba27601e23eab
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 668a80d0f435cdd3ee046af0d3795567f32074fc68bcd8fb6afaec5cbd0023642414771a76c8441b7a7b0acc0d662e00e3cbd229137d068bb2e72a2d15ef8b75
         | 
| 7 | 
            +
              data.tar.gz: 88df5fc4b0c681f4fbce9422979f9d50cbde3742760940a9351380bffba3a2a30beae92326da39db808dc5fa58e067c0322acc9b2d1ee9f30b27c52a4b6c695d
         | 
    
        data/examples/hello-lb.yml
    CHANGED
    
    | @@ -15,8 +15,8 @@ scheduler: | |
| 15 15 | 
             
                  - sg-ZZZZZZZZ
         | 
| 16 16 | 
             
            app:
         | 
| 17 17 | 
             
              image: ryotarai/hello-sinatra
         | 
| 18 | 
            -
              memory:  | 
| 19 | 
            -
              cpu:  | 
| 18 | 
            +
              memory: 128
         | 
| 19 | 
            +
              cpu: 256
         | 
| 20 20 | 
             
              port: 3000
         | 
| 21 21 | 
             
              env:
         | 
| 22 22 | 
             
                $providers:
         | 
| @@ -27,8 +27,8 @@ app: | |
| 27 27 | 
             
            front:
         | 
| 28 28 | 
             
              type: nginx
         | 
| 29 29 | 
             
              image_tag: hako-nginx
         | 
| 30 | 
            -
              memory:  | 
| 31 | 
            -
              cpu:  | 
| 30 | 
            +
              memory: 32
         | 
| 31 | 
            +
              cpu: 32
         | 
| 32 32 | 
             
              s3:
         | 
| 33 33 | 
             
                region: ap-northeast-1
         | 
| 34 34 | 
             
                bucket: nanika
         | 
    
        data/examples/hello.yml
    CHANGED
    
    | @@ -5,9 +5,11 @@ scheduler: | |
| 5 5 | 
             
              desired_count: 2
         | 
| 6 6 | 
             
            app:
         | 
| 7 7 | 
             
              image: ryotarai/hello-sinatra
         | 
| 8 | 
            -
              memory:  | 
| 9 | 
            -
              cpu:  | 
| 8 | 
            +
              memory: 128
         | 
| 9 | 
            +
              cpu: 256
         | 
| 10 10 | 
             
              port: 3000
         | 
| 11 | 
            +
              links:
         | 
| 12 | 
            +
                - redis:redis
         | 
| 11 13 | 
             
              env:
         | 
| 12 14 | 
             
                $providers:
         | 
| 13 15 | 
             
                  - type: file
         | 
| @@ -17,9 +19,14 @@ app: | |
| 17 19 | 
             
            front:
         | 
| 18 20 | 
             
              type: nginx
         | 
| 19 21 | 
             
              image_tag: hako-nginx
         | 
| 20 | 
            -
              memory:  | 
| 21 | 
            -
              cpu:  | 
| 22 | 
            +
              memory: 32
         | 
| 23 | 
            +
              cpu: 32
         | 
| 22 24 | 
             
              s3:
         | 
| 23 25 | 
             
                region: ap-northeast-1
         | 
| 24 26 | 
             
                bucket: nanika
         | 
| 25 27 | 
             
                prefix: hako/front_config
         | 
| 28 | 
            +
            additional_containers:
         | 
| 29 | 
            +
              redis:
         | 
| 30 | 
            +
                image_tag: redis:3.0
         | 
| 31 | 
            +
                cpu: 64
         | 
| 32 | 
            +
                memory: 512
         | 
    
        data/lib/hako/commander.rb
    CHANGED
    
    | @@ -1,4 +1,5 @@ | |
| 1 1 | 
             
            require 'hako/app_container'
         | 
| 2 | 
            +
            require 'hako/container'
         | 
| 2 3 | 
             
            require 'hako/env_expander'
         | 
| 3 4 | 
             
            require 'hako/error'
         | 
| 4 5 | 
             
            require 'hako/fronts'
         | 
| @@ -19,6 +20,9 @@ module Hako | |
| 19 20 | 
             
                  scripts = @app.yaml.fetch('scripts', []).map { |config| load_script(config) }
         | 
| 20 21 |  | 
| 21 22 | 
             
                  containers = { 'app' => app, 'front' => front }
         | 
| 23 | 
            +
                  @app.yaml.fetch('additional_containers', {}).each do |name, container|
         | 
| 24 | 
            +
                    containers[name] = Container.new(@app, container)
         | 
| 25 | 
            +
                  end
         | 
| 22 26 | 
             
                  scripts.each { |script| script.before_deploy(containers) }
         | 
| 23 27 | 
             
                  scheduler.deploy(containers, force: force)
         | 
| 24 28 | 
             
                  scripts.each { |script| script.after_deploy(containers) }
         | 
    
        data/lib/hako/container.rb
    CHANGED
    
    | @@ -2,11 +2,12 @@ module Hako | |
| 2 2 | 
             
              class Container
         | 
| 3 3 | 
             
                DEFAULT_CONFIG = {
         | 
| 4 4 | 
             
                  'docker_labels' => {},
         | 
| 5 | 
            +
                  'links' => [],
         | 
| 5 6 | 
             
                }.freeze
         | 
| 6 7 |  | 
| 7 8 | 
             
                def initialize(app, definition)
         | 
| 8 9 | 
             
                  @app = app
         | 
| 9 | 
            -
                  @definition =  | 
| 10 | 
            +
                  @definition = DEFAULT_CONFIG.merge(definition)
         | 
| 10 11 | 
             
                end
         | 
| 11 12 |  | 
| 12 13 | 
             
                %w[
         | 
| @@ -14,6 +15,7 @@ module Hako | |
| 14 15 | 
             
                  docker_labels
         | 
| 15 16 | 
             
                  cpu
         | 
| 16 17 | 
             
                  memory
         | 
| 18 | 
            +
                  links
         | 
| 17 19 | 
             
                ].each do |name|
         | 
| 18 20 | 
             
                  define_method(name) do
         | 
| 19 21 | 
             
                    @definition[name]
         | 
    
        data/lib/hako/front.rb
    CHANGED
    
    
    
        data/lib/hako/schedulers/ecs.rb
    CHANGED
    
    | @@ -166,12 +166,12 @@ module Hako | |
| 166 166 | 
             
                    task_definition.container_definitions.each do |c|
         | 
| 167 167 | 
             
                      container_definitions[c.name] = c
         | 
| 168 168 | 
             
                    end
         | 
| 169 | 
            -
                    if container_definitions | 
| 169 | 
            +
                    if container_definitions['front']
         | 
| 170 170 | 
             
                      container_definitions['front'].port_mappings[0].host_port
         | 
| 171 171 | 
             
                    end
         | 
| 172 172 | 
             
                  end
         | 
| 173 173 |  | 
| 174 | 
            -
                  def task_definition_changed?( | 
| 174 | 
            +
                  def task_definition_changed?(definitions)
         | 
| 175 175 | 
             
                    if @force_mode
         | 
| 176 176 | 
             
                      return true
         | 
| 177 177 | 
             
                    end
         | 
| @@ -180,7 +180,10 @@ module Hako | |
| 180 180 | 
             
                    task_definition.container_definitions.each do |c|
         | 
| 181 181 | 
             
                      container_definitions[c.name] = c
         | 
| 182 182 | 
             
                    end
         | 
| 183 | 
            -
                     | 
| 183 | 
            +
                    if definitions.any? { |definition| different_definition?(definition, container_definitions.delete(definition[:name])) }
         | 
| 184 | 
            +
                      return true
         | 
| 185 | 
            +
                    end
         | 
| 186 | 
            +
                    !container_definitions.empty?
         | 
| 184 187 | 
             
                  rescue Aws::ECS::Errors::ClientException
         | 
| 185 188 | 
             
                    # Task definition does not exist
         | 
| 186 189 | 
             
                    true
         | 
| @@ -191,12 +194,18 @@ module Hako | |
| 191 194 | 
             
                  end
         | 
| 192 195 |  | 
| 193 196 | 
             
                  def register_task_definition(containers, front_port)
         | 
| 194 | 
            -
                     | 
| 195 | 
            -
             | 
| 196 | 
            -
             | 
| 197 | 
            +
                    definitions = containers.map do |name, container|
         | 
| 198 | 
            +
                      case name
         | 
| 199 | 
            +
                      when 'front'
         | 
| 200 | 
            +
                        front_container(container, front_port)
         | 
| 201 | 
            +
                      else
         | 
| 202 | 
            +
                        app_container(name, container)
         | 
| 203 | 
            +
                      end
         | 
| 204 | 
            +
                    end
         | 
| 205 | 
            +
                    if task_definition_changed?(definitions)
         | 
| 197 206 | 
             
                      @ecs.register_task_definition(
         | 
| 198 207 | 
             
                        family: @app_id,
         | 
| 199 | 
            -
                        container_definitions:  | 
| 208 | 
            +
                        container_definitions: definitions,
         | 
| 200 209 | 
             
                      ).task_definition
         | 
| 201 210 | 
             
                    else
         | 
| 202 211 | 
             
                      :noop
         | 
| @@ -227,7 +236,7 @@ module Hako | |
| 227 236 | 
             
                      image: front.image_tag,
         | 
| 228 237 | 
             
                      cpu: front.cpu,
         | 
| 229 238 | 
             
                      memory: front.memory,
         | 
| 230 | 
            -
                      links:  | 
| 239 | 
            +
                      links: front.links,
         | 
| 231 240 | 
             
                      port_mappings: [{ container_port: 80, host_port: front_port, protocol: 'tcp' }],
         | 
| 232 241 | 
             
                      essential: true,
         | 
| 233 242 | 
             
                      environment: environment,
         | 
| @@ -235,14 +244,14 @@ module Hako | |
| 235 244 | 
             
                    }
         | 
| 236 245 | 
             
                  end
         | 
| 237 246 |  | 
| 238 | 
            -
                  def app_container(app)
         | 
| 247 | 
            +
                  def app_container(name, app)
         | 
| 239 248 | 
             
                    environment = app.env.map { |k, v| { name: k, value: v } }
         | 
| 240 249 | 
             
                    {
         | 
| 241 | 
            -
                      name:  | 
| 250 | 
            +
                      name: name,
         | 
| 242 251 | 
             
                      image: app.image_tag,
         | 
| 243 252 | 
             
                      cpu: app.cpu,
         | 
| 244 253 | 
             
                      memory: app.memory,
         | 
| 245 | 
            -
                      links:  | 
| 254 | 
            +
                      links: app.links,
         | 
| 246 255 | 
             
                      port_mappings: [],
         | 
| 247 256 | 
             
                      essential: true,
         | 
| 248 257 | 
             
                      environment: environment,
         | 
    
        data/lib/hako/version.rb
    CHANGED
    
    
    
        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. | 
| 4 | 
            +
              version: 0.6.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- | 
| 11 | 
            +
            date: 2016-02-22 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: aws-sdk
         |