conjur-debify 1.5.2 → 1.5.3

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
  SHA1:
3
- metadata.gz: ddccb9d6f39996c53c34bea3dc5e877271cb0400
4
- data.tar.gz: 6378ea97813d23a8f4d5b8f1412749db6fdb52be
3
+ metadata.gz: f144ac5f47a96820c0c42b1941adee5e51720335
4
+ data.tar.gz: 4316233ba88c597982eae537cfd9fee00c1d5542
5
5
  SHA512:
6
- metadata.gz: 33d1e81e5fdf92e94ecfba6faac21967adc69339e204e0982221394c9b6d75a2925ea0ae5df66a472f6db7729be241f64ed97744a93caebb46149e9b61c7b1c6
7
- data.tar.gz: 93ca403108dc2b195a9f26006a55de6c7a85470381810236ce32f6bfe64d43098067314b5ab8736e60171e413d74bdb238b7fb154ca4f38ba3d2a155182f3a8f
6
+ metadata.gz: d13e2010bf0aea5cf5e1285e6444ad7fb8225da92056e18533e3546897f78d91c39f64a8f7123e82a9877f1d744ac675b22dc29f3f58c77ba080bbca1ef21bb3
7
+ data.tar.gz: 05dcfd9104f647cfc5a0cd6ea9b8e111d975dd01b01c98af0d9f19b80f6cd09b82e85e14e3c198e03fb9218eb0bc6aa890517c35da10006957364a9db00cd3d9
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 1.5.3
2
+
3
+ * debify now uses `~/.docker/config` auth if pulling an image fails due to auth
4
+
1
5
  # 1.5.2
2
6
 
3
7
  * Use new conjurops variables in `publish` command, fall back to old conjurops
data/debify.gemspec CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.require_paths = ["lib"]
19
19
 
20
20
  spec.add_dependency "gli"
21
- spec.add_dependency "docker-api"
21
+ spec.add_dependency "docker-api", "~> 1.33"
22
22
  spec.add_dependency "conjur-cli"
23
23
 
24
24
  spec.add_development_dependency "bundler", "~> 1.7"
@@ -1,5 +1,5 @@
1
1
  module Conjur
2
2
  module Debify
3
- VERSION = "1.5.2"
3
+ VERSION = "1.5.3"
4
4
  end
5
5
  end
data/lib/conjur/debify.rb CHANGED
@@ -2,6 +2,8 @@ require "conjur/debify/version"
2
2
  require 'docker'
3
3
  require 'fileutils'
4
4
  require 'gli'
5
+ require 'json'
6
+ require 'base64'
5
7
 
6
8
  include GLI::App
7
9
 
@@ -84,6 +86,20 @@ def git_files
84
86
  (`git ls-files -z`.split("\x0") + ['Gemfile.lock']).uniq
85
87
  end
86
88
 
89
+ def login_to_registry(appliance_image_id)
90
+ config_file = File.expand_path('~/.docker/config.json')
91
+ if File.exist? config_file
92
+ json_config = JSON.parse(File.read(config_file))
93
+ registry = appliance_image_id.split('/')[0]
94
+
95
+ json_auth = json_config['auths'][registry]['auth']
96
+ if json_auth
97
+ username, password = Base64.decode64(json_auth).split(':')
98
+ Docker.authenticate! username: username, password: password, serveraddress: registry
99
+ end
100
+ end
101
+ end
102
+
87
103
  desc "Clean current working directory of non-Git-managed files"
88
104
  long_desc <<DESC
89
105
  Reliable builds depend on having a clean working directory.
@@ -341,7 +357,7 @@ command "test" do |c|
341
357
  raise "project-name is required" unless project_name = args.shift
342
358
  raise "test-script is required" unless test_script = args.shift
343
359
  raise "Received extra command-line arguments" if args.shift
344
-
360
+
345
361
  dir = cmd_options[:dir] || '.'
346
362
  dir = File.expand_path(dir)
347
363
 
@@ -355,8 +371,15 @@ command "test" do |c|
355
371
  package_name = "conjur-#{project_name}_#{version}_amd64.deb"
356
372
 
357
373
  raise "#{test_script} does not exist or is not a file" unless File.file?(test_script)
358
-
359
- Docker::Image.create 'fromImage' => appliance_image_id, &DebugMixin::DOCKER if cmd_options[:pull]
374
+
375
+ begin
376
+ tries ||=2
377
+ Docker::Image.create 'fromImage' => appliance_image_id, &DebugMixin::DOCKER if cmd_options[:pull]
378
+ rescue
379
+ login_to_registry appliance_image_id
380
+ retry unless (tries -= 1).zero?
381
+ end
382
+
360
383
 
361
384
  def build_test_image(appliance_image_id, project_name, package_name)
362
385
  dockerfile = <<-DOCKERFILE
@@ -384,7 +407,13 @@ RUN touch /etc/service/conjur/down
384
407
  end
385
408
  end
386
409
 
387
- appliance_image = build_test_image(appliance_image_id, project_name, package_name)
410
+ begin
411
+ tries ||=2
412
+ appliance_image = build_test_image(appliance_image_id, project_name, package_name)
413
+ rescue
414
+ login_to_registry appliance_image_id
415
+ retry unless (tries -= 1).zero?
416
+ end
388
417
 
389
418
  vendor_dir = File.expand_path("tmp/debify/#{project_name}/vendor", ENV['HOME'])
390
419
  dot_bundle_dir = File.expand_path("tmp/debify/#{project_name}/.bundle", ENV['HOME'])
@@ -511,7 +540,13 @@ command "sandbox" do |c|
511
540
  appliance_image_id = [ cmd_options[:image], image_tag ].join(":")
512
541
 
513
542
  appliance_image = if cmd_options[:pull]
514
- Docker::Image.create 'fromImage' => appliance_image_id, &DebugMixin::DOCKER if cmd_options[:pull]
543
+ begin
544
+ tries ||=2
545
+ Docker::Image.create 'fromImage' => appliance_image_id, &DebugMixin::DOCKER if cmd_options[:pull]
546
+ rescue
547
+ login_to_registry appliance_image_id
548
+ retry unless (tries -= 1).zero?
549
+ end
515
550
  else
516
551
  Docker::Image.get appliance_image_id
517
552
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: conjur-debify
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.2
4
+ version: 1.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Gilpin
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: docker-api
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '1.33'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '1.33'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: conjur-cli
43
43
  requirement: !ruby/object:Gem::Requirement