nutkins 0.10.0 → 0.10.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/nutkins.rb +24 -19
  3. data/lib/nutkins/version.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e73d665ef1da7e2713d6d7ab469d963f50969c39
4
- data.tar.gz: 02399c0c0dca4636432ec49625978433b9e3f994
3
+ metadata.gz: 9873753bcc6bffb9546adf4022433732facc78c0
4
+ data.tar.gz: 15bfa779ab8115550d137f02ebb1591524ff4763
5
5
  SHA512:
6
- metadata.gz: 6d0cc75a3a1d4b93d7ffc50ebed8233e69d3c17577cabffe1f96e94a4aee7ac94432b683e479b5fdd83f11f390bd6c2003ce699d5dac4ed259429b54c4e6b140
7
- data.tar.gz: eca9bb3a1db88257cf7813e0eb62fe2cab4c5ec7b41067ac4d691f010b9de3ac9a778f505ec1370c441a3ec4559a9e5faff6e9d0c92a7ac7eaba3630498f1256
6
+ metadata.gz: 0ec0681915beb261b91a511ec5f5bcd79b46722df1f230d5cbb3caf025ba6182ea99ce236f2a4bf0f8b82fd1666a7bb0824f6a1bff79d16fdeab5f257f261527
7
+ data.tar.gz: cd44f7e126e9feaf8253d0c0b6c94874b712ba168857657bcec282897761de689ba659d4ffb0a3e2d43ad3857b78f93da8636403536bf891f83b02d9e6a6130a
@@ -15,6 +15,9 @@ require "nutkins/version"
15
15
 
16
16
  require_relative "hash_dig"
17
17
 
18
+ # throughout this file "path" is a directory, it should be "." or a single path like "directory"
19
+ # which should correspond to a directory within the project root containing a nutkin.yaml
20
+
18
21
  # Must be somedomain.net instead of somedomain.net/, otherwise, it will throw exception.
19
22
  module Nutkins
20
23
  CONFIG_FILE_NAME = 'nutkins.yaml'
@@ -48,9 +51,11 @@ module Nutkins
48
51
  # TODO: flag to suppress building base image?
49
52
  base = cfg['base']
50
53
  unless @built[base]
51
- if image_in_project? base
54
+ base_cfg = config_for_image base
55
+ if base_cfg
56
+ base_path = base_cfg['path']
52
57
  puts "building parent of #{img_name}: #{base}"
53
- build base
58
+ build base_path
54
59
  end
55
60
  end
56
61
  prev_image_id = Docker.image_id_for_tag tag
@@ -204,15 +209,15 @@ module Nutkins
204
209
  File.unlink secret if path_is_dir
205
210
  end
206
211
 
207
- def extract_secrets img_dirs
208
- if img_dirs.empty?
209
- img_dirs = get_all_img_dirs
212
+ def extract_secrets paths
213
+ if paths.empty?
214
+ paths = get_all_img_paths
210
215
  # there may be secrets in the root even if there is no image build there
211
- img_dirs.push '.' unless img_dirs.include? '.'
216
+ paths.push '.' unless paths.include? '.'
212
217
  end
213
218
 
214
- img_dirs.each do |img_dir|
215
- get_secrets(img_dir).each do |secret|
219
+ paths.each do |path|
220
+ get_secrets(path).each do |secret|
216
221
  loop do
217
222
  puts "enter passphrase for #{secret}"
218
223
  break if system 'gpg', secret
@@ -253,8 +258,8 @@ module Nutkins
253
258
  '-advertise-client-urls', "http://#{gateway}:#{ETCD_PORT}",
254
259
  '-listen-client-urls', "http://0.0.0.0:#{ETCD_PORT}"
255
260
 
256
- img_dirs = get_all_img_dirs
257
- configs = img_dirs.map &method(:get_image_config)
261
+ all_paths = get_all_img_paths
262
+ configs = all_paths.map &method(:get_image_config)
258
263
  etcd_store = {}
259
264
  configs.each do |config|
260
265
  etcd_store.merge! config['etcd']['data'] if config.dig('etcd', 'data')
@@ -328,19 +333,19 @@ module Nutkins
328
333
  raise "missing #{img_cfg_path}" unless File.exists?(img_cfg_path)
329
334
  img_cfg = YAML.load_file(img_cfg_path)
330
335
  img_cfg['image'] ||= path if path != '.'
331
- raise "#{img_cfg_path} must contain 'image' entry" unless img_cfg['image']
336
+ img_cfg['path'] = path
337
+ raise "#{img_cfg_path} must contain `image' entry" unless img_cfg['image']
332
338
 
333
339
  img_cfg['shell'] ||= '/bin/sh'
334
- img_cfg['path'] ||= img_cfg_path
335
340
  img_cfg['directory'] = directory
336
341
  img_cfg["version"] ||= @config.version if @config.version
337
342
  img_cfg['version'] = img_cfg['version'].to_s
338
- raise "#{img_cfg_path} must contain 'version' entry" unless img_cfg.has_key? 'version'
343
+ raise "#{img_cfg_path} must contain `version' entry" unless img_cfg.has_key? 'version'
339
344
  img_cfg['latest_tag'] = get_tag img_cfg
340
345
  img_cfg['tag'] = img_cfg['latest_tag'] + ':' + img_cfg['version']
341
346
 
342
347
  base = img_cfg['base']
343
- raise "#{img_cfg_path} must include `base` field" unless base
348
+ raise "#{img_cfg_path} must include `base' field" unless base
344
349
  @img_configs[path] = img_cfg
345
350
  end
346
351
 
@@ -356,20 +361,20 @@ module Nutkins
356
361
  repository + '/' + img_cfg['image']
357
362
  end
358
363
 
359
- def get_all_img_dirs
364
+ def get_all_img_paths
360
365
  Dir.glob("#{@project_root}{,/*}/nutkin.yaml").map do |path|
361
366
  File.basename File.dirname(path)
362
367
  end
363
368
  end
364
369
 
365
- def image_in_project? image_name
366
- get_all_img_dirs.map(&method(:get_image_config)).find do |cfg|
370
+ def config_for_image image_name
371
+ get_all_img_paths.map(&method(:get_image_config)).find do |cfg|
367
372
  cfg['image'] == image_name
368
373
  end
369
374
  end
370
375
 
371
- def get_secrets img_dir
372
- Dir.glob("#{img_dir}/{volumes,secrets}/*.gpg")
376
+ def get_secrets path
377
+ Dir.glob("#{path}/{volumes,secrets}/*.gpg")
373
378
  end
374
379
 
375
380
  private
@@ -1,3 +1,3 @@
1
1
  module Nutkins
2
- VERSION = "0.10.0"
2
+ VERSION = "0.10.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nutkins
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Pike