hako 2.0.0 → 2.0.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 85ef57c377dafbf524ddb4d442108f92aee5f278d2506c5f91ca61df1541dd2b
4
- data.tar.gz: 7de25a114cf37299e18ffa034d8eed56d6253857c67865bd0a15f90c1c87bb02
3
+ metadata.gz: b1f36ce62c2bec8de3106ea4c8cda86ca908403a1463afa50da98fd753514cb7
4
+ data.tar.gz: 22d21c3a01bc721b35dfb2d6956bd0f68c9e6599a534b9e3ad2c0b875145b604
5
5
  SHA512:
6
- metadata.gz: a30d023690fc56f462e230b0e9b229c63091489446ac85c45a01d7158d0ba363f999ea28ca0cac2a2c9c22dfb387f3a7d5cc8b5fcd9a552fb98581f518eedeee
7
- data.tar.gz: 2095d02a1a7da744416a599abf5ba16762206349c4dfd772d7d74f7ef030aab4ffa4a6a4d36005f68d42fdced3e82c2bdbef51b4a0ea1839cdd4b07432709da2
6
+ metadata.gz: 5710cce2fdbf9f31e371889027dc6d0152e076d011935f084402e7b5077aed83917ca97c56cd14e57427bdcbe152e104ffeb1a0bb9ea51d6beae9fabded554a2
7
+ data.tar.gz: 27e189dd2d0fa39b1180bff7a0ad77b044d85912d09508069f51cc9c6795bebf3e44d0f5206409599dabda801146a567a47f43d61345f3939548ffa433df4858
@@ -1,3 +1,7 @@
1
+ # 2.0.1 (2017-12-14)
2
+ ## Bug fixes
3
+ - Fix compatibility between Jsonnet and YAML when --dry-run is given
4
+
1
5
  # 2.0.0 (2017-12-13)
2
6
  ## New features
3
7
  - Support Jsonnet as the definition file format
@@ -15,7 +15,7 @@ module Hako
15
15
  # @return [Hash]
16
16
  attr_reader :id, :root_path, :definition
17
17
 
18
- def initialize(yaml_path, expand_variables: true)
18
+ def initialize(yaml_path, expand_variables: true, ask_keys: false)
19
19
  path = Pathname.new(yaml_path)
20
20
  @id = path.basename.sub_ext('').to_s
21
21
  @root_path = path.parent
@@ -24,7 +24,7 @@ module Hako
24
24
  when '.yml', '.yaml'
25
25
  YamlLoader.new.load(path)
26
26
  when '.jsonnet', '.json'
27
- JsonnetLoader.new(self, expand_variables).load(path)
27
+ JsonnetLoader.new(self, expand_variables: expand_variables, ask_keys: ask_keys).load(path)
28
28
  else
29
29
  raise Error.new("Unknown extension: #{path}")
30
30
  end
@@ -66,7 +66,13 @@ module Hako
66
66
  Hako.logger.level = Logger::DEBUG
67
67
  end
68
68
 
69
- Commander.new(Application.new(@yaml_path)).deploy(force: @force, tag: @tag, dry_run: @dry_run, timeout: @timeout)
69
+ options =
70
+ if @dry_run
71
+ { expand_variables: false, ask_keys: true }
72
+ else
73
+ {}
74
+ end
75
+ Commander.new(Application.new(@yaml_path, options)).deploy(force: @force, tag: @tag, dry_run: @dry_run, timeout: @timeout)
70
76
  end
71
77
 
72
78
  DEFAULT_TIMEOUT = 1200 # 20 minutes
@@ -109,7 +115,13 @@ module Hako
109
115
  Hako.logger.level = Logger::DEBUG
110
116
  end
111
117
 
112
- Commander.new(Application.new(@yaml_path)).rollback(dry_run: @dry_run)
118
+ options =
119
+ if @dry_run
120
+ { expand_variables: false, ask_keys: true }
121
+ else
122
+ {}
123
+ end
124
+ Commander.new(Application.new(@yaml_path, options)).rollback(dry_run: @dry_run)
113
125
  end
114
126
 
115
127
  def parse!(argv)
@@ -144,7 +156,13 @@ module Hako
144
156
  Hako.logger.level = Logger::DEBUG
145
157
  end
146
158
 
147
- Commander.new(Application.new(@yaml_path)).oneshot(@argv, tag: @tag, containers: @containers, env: @env, dry_run: @dry_run, no_wait: @no_wait)
159
+ options =
160
+ if @dry_run
161
+ { expand_variables: false, ask_keys: true }
162
+ else
163
+ {}
164
+ end
165
+ Commander.new(Application.new(@yaml_path, options)).oneshot(@argv, tag: @tag, containers: @containers, env: @env, dry_run: @dry_run, no_wait: @no_wait)
148
166
  end
149
167
 
150
168
  def parse!(argv)
@@ -213,7 +231,7 @@ module Hako
213
231
  parse!(argv)
214
232
  require 'hako/application'
215
233
  require 'hako/commander'
216
- Commander.new(Application.new(@yaml_path)).status
234
+ Commander.new(Application.new(@yaml_path, expand_variables: false)).status
217
235
  end
218
236
 
219
237
  def parse!(argv)
@@ -239,7 +257,14 @@ module Hako
239
257
  parse!(argv)
240
258
  require 'hako/application'
241
259
  require 'hako/commander'
242
- Commander.new(Application.new(@yaml_path)).remove(dry_run: @dry_run)
260
+
261
+ options =
262
+ if @dry_run
263
+ { expand_variables: false, ask_keys: true }
264
+ else
265
+ {}
266
+ end
267
+ Commander.new(Application.new(@yaml_path, options)).remove(dry_run: @dry_run)
243
268
  end
244
269
 
245
270
  def parse!(argv)
@@ -267,7 +292,14 @@ module Hako
267
292
  parse!(argv)
268
293
  require 'hako/application'
269
294
  require 'hako/commander'
270
- Commander.new(Application.new(@yaml_path)).stop(dry_run: @dry_run)
295
+
296
+ options =
297
+ if @dry_run
298
+ { expand_variables: false, ask_keys: true }
299
+ else
300
+ {}
301
+ end
302
+ Commander.new(Application.new(@yaml_path, options)).stop(dry_run: @dry_run)
271
303
  end
272
304
 
273
305
  def parse!(argv)
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'hako'
4
4
  require 'hako/env_providers'
5
+ require 'hako/error'
5
6
  require 'hako/loader'
6
7
  require 'json'
7
8
  require 'jsonnet'
@@ -10,10 +11,11 @@ module Hako
10
11
  class JsonnetLoader
11
12
  # @param [Application] application
12
13
  # @param [Boolean] expand_variables
13
- def initialize(application, expand_variables)
14
+ # @param [Boolean] ask_keys
15
+ def initialize(application, expand_variables:, ask_keys:)
14
16
  @vm = Jsonnet::VM.new
15
17
  @root_path = application.root_path
16
- define_provider_functions(expand_variables)
18
+ define_provider_functions(expand_variables, ask_keys)
17
19
  @vm.ext_var('appId', application.id)
18
20
  end
19
21
 
@@ -24,7 +26,7 @@ module Hako
24
26
 
25
27
  private
26
28
 
27
- def define_provider_functions(expand_variables)
29
+ def define_provider_functions(expand_variables, ask_keys)
28
30
  Gem.loaded_specs.each do |gem_name, spec|
29
31
  spec.require_paths.each do |path|
30
32
  Dir.glob(File.join(spec.full_gem_path, path, 'hako/env_providers/*.rb')).each do |provider_path|
@@ -35,7 +37,15 @@ module Hako
35
37
  if expand_variables
36
38
  provider_class.new(@root_path, JSON.parse(options)).ask([name]).fetch(name)
37
39
  else
38
- "\#{#{name}}"
40
+ if ask_keys
41
+ provider = provider_class.new(@root_path, JSON.parse(options))
42
+ if provider.can_ask_keys?
43
+ if provider.ask_keys([name]).empty?
44
+ raise Error.new("Could not lookup #{name} from #{provider_name} provider with options=#{options}")
45
+ end
46
+ end
47
+ end
48
+ "${#{name}}"
39
49
  end
40
50
  end
41
51
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Hako
4
- VERSION = '2.0.0'
4
+ VERSION = '2.0.1'
5
5
  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: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kohei Suzuki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-12-13 00:00:00.000000000 Z
11
+ date: 2017-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-applicationautoscaling