bako 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'yaml'
2
4
  require 'pathname'
3
5
 
@@ -8,32 +10,28 @@ module Bako
8
10
 
9
11
  attr_reader :name, :command, :role_arn, :image, :type, :arn, :memory, :vcpus
10
12
 
11
- def self.from_context(context)
13
+ def self.from_context(context, dry_run: false)
12
14
  new(
13
15
  context.name,
14
- context.command_b,
15
- context.image_b,
16
- context.role_arn_b,
17
- context.type_b,
18
- context.memory_b,
19
- context.vcpus_b
16
+ context.result,
17
+ dry_run: dry_run
20
18
  )
21
19
  end
22
20
 
23
- def initialize(name, command, image, role_arn, type, memory, vcpus)
21
+ def initialize(name, result, dry_run: false)
24
22
  @name = name
25
- @command = command
26
- @image = image
27
- @role_arn = role_arn
28
- @type = type
29
- @memory = memory
30
- @vcpus = vcpus
23
+ @command = result[:command]
24
+ @image = result[:image]
25
+ @role_arn = result[:role_arn]
26
+ @type = result[:type]
27
+ @memory = result[:memory]
28
+ @vcpus = result[:vcpus]
29
+ @dry_run = dry_run
31
30
  end
32
31
 
33
32
  def register
34
33
  Bako.logger.info("Registering JobDefinition #{@name}")
35
-
36
- resp = batch_client.register_job_definition({
34
+ jd_arg = {
37
35
  type: @type,
38
36
  container_properties: {
39
37
  command: @command,
@@ -42,10 +40,20 @@ module Bako
42
40
  vcpus: @vcpus || DEFAULTS[:vcpus],
43
41
  },
44
42
  job_definition_name: @name
45
- })
43
+ }
44
+
45
+ Bako.logger.info("\n#{jd_arg.to_yaml}\n")
46
+
47
+ if @dry_run
48
+ @arn = 'dry_run'
49
+ @revision = 'dry_run'
50
+ else
51
+ resp = batch_client.register_job_definition(jd_arg)
52
+
53
+ @arn = resp.job_definition_arn
54
+ @revision = resp.revision
55
+ end
46
56
 
47
- @arn = resp.job_definition_arn
48
- @revision = resp.revision
49
57
  Bako.logger.info("Registered JobDefinition #{@name}:#{@revision} (arn: #{@arn})")
50
58
  end
51
59
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Bako
2
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
3
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bako
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuichiro Someya
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-04-14 00:00:00.000000000 Z
11
+ date: 2017-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0.19'
97
+ - !ruby/object:Gem::Dependency
98
+ name: activesupport
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '5.0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '5.0'
97
111
  description: AWS Batch DSL and a set of cli tool.
98
112
  email:
99
113
  - ayemos.y@gmail.com
@@ -102,8 +116,11 @@ executables:
102
116
  extensions: []
103
117
  extra_rdoc_files: []
104
118
  files:
119
+ - ".codeclimate.yml"
105
120
  - ".gitignore"
106
121
  - ".rspec"
122
+ - ".rubocop.yml"
123
+ - ".ruby-version"
107
124
  - ".travis.yml"
108
125
  - Gemfile
109
126
  - README.md