rake_docker 0.23.0 → 0.24.0.pre.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7de502904698c71b14259c3d9ba227bc056ce6108c6da20943011f585c33b99e
4
- data.tar.gz: 282797aa0d998ace0f984aabe225d6c9f7506da286d481f223ef66ff6e649602
3
+ metadata.gz: eefb362c6bf5ff46977457705c5b7b7a61af8b5c158c0c1657e22cdbe9d5927c
4
+ data.tar.gz: bcf827cb079c304dc563c28ea248af8c097eee78d7f9063b5fb48102a9dbc691
5
5
  SHA512:
6
- metadata.gz: a0c8dc3dca487d758878423d4985cbf0fba6bb78c7c668e54b554eb9a44b54b1fc362c1fde2215311a8b94f3c83e82e7ac89081b2aec0e6753a0c64bc2a7ef8f
7
- data.tar.gz: 953195aee0aff1f2a81eaa2784999c7af8ee1721fc856776475c5f93104fbacabb78b54a3407166ad7a6e3eb9b12debad79b02a7de82209ac320b2ea513b4749
6
+ metadata.gz: d445212ce34c610f2481d79fba5b2d73e8e820a7e1745f796087912174b2a3cd7f50dfe99401b56e7fc4225d7a556c8984cf985b79233a37fa005e0dfcaaa2f2
7
+ data.tar.gz: a6b2eccd2a8c8e4762cdfbf1d2ed50d6c6cd23ae6df53b07926ed38b0826d2661ffbe20eca1ebc2ec3683664b34d3eafc3f2ddee6676b0a17ca44046a1cb80bf
data/.circleci/config.yml CHANGED
@@ -3,14 +3,14 @@ jobs:
3
3
  test:
4
4
  working_directory: ~/rake-docker
5
5
  docker:
6
- - image: ruby:2.3.8
6
+ - image: ruby:2.6.0
7
7
  steps:
8
8
  - checkout
9
9
  - run: ./scripts/ci/steps/test.sh
10
10
  prerelease:
11
11
  working_directory: ~/rake-docker
12
12
  docker:
13
- - image: ruby:2.3.8
13
+ - image: ruby:2.6.0
14
14
  steps:
15
15
  - checkout
16
16
  - run: ./scripts/ci/common/install-git-crypt.sh
@@ -21,7 +21,7 @@ jobs:
21
21
  release:
22
22
  working_directory: ~/rake-docker
23
23
  docker:
24
- - image: ruby:2.3.8
24
+ - image: ruby:2.6.0
25
25
  steps:
26
26
  - checkout
27
27
  - run: ./scripts/ci/common/install-git-crypt.sh
data/.gitignore CHANGED
@@ -1,6 +1,7 @@
1
1
  ## Standard stuff:
2
2
  *.gem
3
3
  *.rbc
4
+ /build
4
5
  /.config
5
6
  /coverage/
6
7
  /InstalledFiles
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.3.8
1
+ 2.6.0
data/Gemfile.lock CHANGED
@@ -1,70 +1,72 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rake_docker (0.23.0)
4
+ rake_docker (0.24.0.pre.1)
5
5
  aws-sdk-ecr (~> 1.2)
6
6
  colored2 (~> 3.1)
7
7
  docker-api (~> 1.34)
8
+ rake_factory (~> 0.15)
8
9
 
9
10
  GEM
10
11
  remote: https://rubygems.org/
11
12
  specs:
12
- activesupport (5.2.1)
13
+ activesupport (5.2.4.1)
13
14
  concurrent-ruby (~> 1.0, >= 1.0.2)
14
15
  i18n (>= 0.7, < 2)
15
16
  minitest (~> 5.1)
16
17
  tzinfo (~> 1.1)
17
- aws-eventstream (1.0.2)
18
- aws-partitions (1.144.0)
19
- aws-sdk-core (3.47.0)
18
+ aws-eventstream (1.0.3)
19
+ aws-partitions (1.267.0)
20
+ aws-sdk-core (3.89.1)
20
21
  aws-eventstream (~> 1.0, >= 1.0.2)
21
- aws-partitions (~> 1.0)
22
+ aws-partitions (~> 1, >= 1.239.0)
22
23
  aws-sigv4 (~> 1.1)
23
- http-2 (~> 0.10)
24
24
  jmespath (~> 1.0)
25
- aws-sdk-ecr (1.12.0)
26
- aws-sdk-core (~> 3, >= 3.47.0)
25
+ aws-sdk-ecr (1.24.0)
26
+ aws-sdk-core (~> 3, >= 3.71.0)
27
27
  aws-sigv4 (~> 1.1)
28
28
  aws-sigv4 (1.1.0)
29
29
  aws-eventstream (~> 1.0, >= 1.0.2)
30
30
  colored2 (3.1.2)
31
- concurrent-ruby (1.1.3)
31
+ concurrent-ruby (1.1.5)
32
32
  diff-lcs (1.3)
33
- docile (1.3.1)
33
+ docile (1.3.2)
34
34
  docker-api (1.34.2)
35
35
  excon (>= 0.47.0)
36
36
  multi_json
37
- excon (0.62.0)
38
- gem-release (2.0.1)
39
- http-2 (0.10.1)
40
- i18n (1.1.1)
37
+ excon (0.71.1)
38
+ gem-release (2.1.1)
39
+ i18n (1.8.2)
41
40
  concurrent-ruby (~> 1.0)
42
41
  jmespath (1.4.0)
43
- json (2.1.0)
42
+ json (2.3.0)
44
43
  memfs (1.0.0)
45
- minitest (5.11.3)
46
- multi_json (1.13.1)
47
- rake (12.3.1)
48
- rspec (3.8.0)
49
- rspec-core (~> 3.8.0)
50
- rspec-expectations (~> 3.8.0)
51
- rspec-mocks (~> 3.8.0)
52
- rspec-core (3.8.0)
53
- rspec-support (~> 3.8.0)
54
- rspec-expectations (3.8.2)
44
+ minitest (5.14.0)
45
+ multi_json (1.14.1)
46
+ rake (13.0.1)
47
+ rake_factory (0.15.0)
48
+ activesupport (~> 5.2)
49
+ rake (~> 13.0)
50
+ rspec (3.9.0)
51
+ rspec-core (~> 3.9.0)
52
+ rspec-expectations (~> 3.9.0)
53
+ rspec-mocks (~> 3.9.0)
54
+ rspec-core (3.9.1)
55
+ rspec-support (~> 3.9.1)
56
+ rspec-expectations (3.9.0)
55
57
  diff-lcs (>= 1.2.0, < 2.0)
56
- rspec-support (~> 3.8.0)
57
- rspec-mocks (3.8.0)
58
+ rspec-support (~> 3.9.0)
59
+ rspec-mocks (3.9.1)
58
60
  diff-lcs (>= 1.2.0, < 2.0)
59
- rspec-support (~> 3.8.0)
60
- rspec-support (3.8.0)
61
- simplecov (0.16.1)
61
+ rspec-support (~> 3.9.0)
62
+ rspec-support (3.9.2)
63
+ simplecov (0.17.1)
62
64
  docile (~> 1.1)
63
65
  json (>= 1.8, < 3)
64
66
  simplecov-html (~> 0.10.0)
65
67
  simplecov-html (0.10.2)
66
68
  thread_safe (0.3.6)
67
- tzinfo (1.2.5)
69
+ tzinfo (1.2.6)
68
70
  thread_safe (~> 0.1)
69
71
 
70
72
  PLATFORMS
@@ -72,13 +74,13 @@ PLATFORMS
72
74
 
73
75
  DEPENDENCIES
74
76
  activesupport (~> 5.2)
75
- bundler (~> 1.16)
77
+ bundler (~> 2.0)
76
78
  gem-release (~> 2.0)
77
79
  memfs (~> 1.0)
78
- rake (~> 12.3)
80
+ rake (~> 13.0)
79
81
  rake_docker!
80
- rspec (~> 3.8)
82
+ rspec (~> 3.9)
81
83
  simplecov (~> 0.16)
82
84
 
83
85
  BUNDLED WITH
84
- 1.17.3
86
+ 2.1.4
data/lib/rake_docker.rb CHANGED
@@ -1,9 +1,12 @@
1
1
  require 'rake_docker/version'
2
+ require 'rake_docker/output'
3
+ require 'rake_docker/exceptions'
2
4
  require 'rake_docker/tasks'
5
+ require 'rake_docker/task_sets'
3
6
  require 'rake_docker/authentication'
4
7
 
5
8
  module RakeDocker
6
- def self.define_image_tasks(&block)
7
- RakeDocker::Tasks::All.new(&block)
9
+ def self.define_image_tasks(opts = {}, &block)
10
+ RakeDocker::TaskSets::All.define(opts, &block)
8
11
  end
9
12
  end
@@ -1,7 +1,4 @@
1
1
  module RakeDocker
2
- class RequiredParameterUnset < ::StandardError
3
- end
4
-
5
2
  class ImageNotFound < ::StandardError
6
3
  end
7
4
  end
@@ -0,0 +1,49 @@
1
+ require 'json'
2
+ require 'colored2'
3
+
4
+ module RakeDocker
5
+ module Output
6
+ def self.parse(chunk)
7
+ chunk.each_line do |line|
8
+ yield self.parse_line(line)
9
+ end
10
+ end
11
+
12
+ def self.parse_line(line)
13
+ begin
14
+ json = JSON.parse(line.strip)
15
+ rescue JSON::ParserError
16
+ return line
17
+ end
18
+
19
+ # Skip progress and aux as they are covered by other status messages
20
+ return '' if json['progress'] && json['status']
21
+ return '' if json['aux']
22
+
23
+ # Return error flag as a second result
24
+ return [json['error'], true] if json['error']
25
+
26
+ return json['stream'] if json['stream']
27
+
28
+ if json['status']
29
+ if json['id']
30
+ return json['id'] + ': ' + json['status'] + "\n"
31
+ else
32
+ return json['status'] + "\n"
33
+ end
34
+ end
35
+
36
+ return line
37
+ end
38
+
39
+ def self.print(chunk)
40
+ self.parse(chunk) do |text, is_error|
41
+ if is_error
42
+ $stdout.print text.red + "\n"
43
+ raise text
44
+ end
45
+ $stdout.print text unless text.empty?
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1 @@
1
+ require_relative 'task_sets/all'
@@ -0,0 +1,41 @@
1
+ require 'rake_factory'
2
+ require 'docker'
3
+
4
+ require_relative '../tasks'
5
+
6
+ module RakeDocker
7
+ module TaskSets
8
+ class All < RakeFactory::TaskSet
9
+ prepend RakeFactory::Namespaceable
10
+
11
+ parameter :image_name, required: true
12
+ parameter :repository_name, required: true
13
+ parameter :repository_url, required: true
14
+
15
+ parameter :work_directory, required: true
16
+
17
+ parameter :copy_spec, default: []
18
+ parameter :create_spec, default: []
19
+
20
+ parameter :argument_names, default: []
21
+
22
+ parameter :tags, required: true
23
+
24
+ parameter :credentials
25
+
26
+ parameter :build_args
27
+
28
+ parameter :clean_task_name, default: :clean
29
+ parameter :prepare_task_name, default: :prepare
30
+ parameter :build_task_name, default: :build
31
+ parameter :tag_task_name, default: :tag
32
+ parameter :push_task_name, default: :push
33
+
34
+ task Tasks::Clean, name: ->(ts) { ts.clean_task_name }
35
+ task Tasks::Prepare, name: ->(ts) { ts.prepare_task_name }
36
+ task Tasks::Build, name: ->(ts) { ts.build_task_name }
37
+ task Tasks::Tag, name: ->(ts) { ts.tag_task_name }
38
+ task Tasks::Push, name: ->(ts) { ts.push_task_name }
39
+ end
40
+ end
41
+ end
@@ -3,4 +3,3 @@ require_relative 'tasks/prepare'
3
3
  require_relative 'tasks/build'
4
4
  require_relative 'tasks/tag'
5
5
  require_relative 'tasks/push'
6
- require_relative 'tasks/all'
@@ -1,12 +1,19 @@
1
+ require 'rake_factory'
1
2
  require 'docker'
2
- require_relative '../tasklib'
3
- require_relative '../../docker_output'
3
+
4
+ require_relative '../output'
4
5
 
5
6
  module RakeDocker
6
7
  module Tasks
7
- class Build < TaskLib
8
- parameter :name, :default => :build
9
- parameter :argument_names, :default => []
8
+ class Build < RakeFactory::Task
9
+ default_name :build
10
+ default_description ->(t) { "Build #{t.image_name} image" }
11
+ default_prerequisites ->(t) {
12
+ t.prepare_task_name ?
13
+ [Rake.application.current_scope
14
+ .path_with_task_name(t.prepare_task_name)] :
15
+ []
16
+ }
10
17
 
11
18
  parameter :image_name, :required => true
12
19
  parameter :repository_name, :required => true
@@ -17,49 +24,22 @@ module RakeDocker
17
24
 
18
25
  parameter :work_directory, :required => true
19
26
 
20
- parameter :prepare_task, :default => :prepare
21
-
22
- def process_arguments(args)
23
- self.name = args[0] if args[0]
24
- end
25
-
26
- def define
27
- prerequisites = prepare_task ?
28
- [scoped_task_name(prepare_task)] :
29
- []
27
+ parameter :prepare_task_name, :default => :prepare
30
28
 
31
- desc "Build #{image_name} image"
32
- task name, argument_names => prerequisites do |_, args|
33
- params = OpenStruct.new(
34
- image_name: image_name,
35
- repository_name: repository_name,
36
- credentials: credentials,
37
- work_directory: work_directory
38
- )
29
+ action do |t|
30
+ Docker.authenticate!(t.credentials) if t.credentials
39
31
 
40
- derived_credentials = credentials.respond_to?(:call) ?
41
- credentials.call(*[args, params].slice(0, credentials.arity)) :
42
- credentials
32
+ options = {t: t.repository_name}
33
+ options = options.merge(
34
+ buildargs: JSON.generate(t.build_args)) if t.build_args
43
35
 
44
- Docker.authenticate!(derived_credentials) if derived_credentials
45
-
46
- options = {t: repository_name}
47
- options = options.merge(
48
- buildargs: JSON.generate(build_args)) if build_args
49
-
50
- Docker::Image.build_from_dir(
51
- File.join(work_directory, image_name),
52
- options) do |chunk|
53
- DockerOutput.print chunk
54
- end
36
+ Docker::Image.build_from_dir(
37
+ File.join(t.work_directory, t.image_name),
38
+ options
39
+ ) do |chunk|
40
+ Output.print chunk
55
41
  end
56
42
  end
57
-
58
- private
59
-
60
- def scoped_task_name(task_name)
61
- Rake.application.current_scope.path_with_task_name(task_name)
62
- end
63
43
  end
64
44
  end
65
45
  end
@@ -1,22 +1,18 @@
1
- require_relative '../tasklib'
1
+ require 'rake_factory'
2
2
 
3
3
  module RakeDocker
4
4
  module Tasks
5
- class Clean < TaskLib
6
- parameter :name, :default => :clean
5
+ class Clean < RakeFactory::Task
6
+ default_name :clean
7
+ default_description ->(t) {
8
+ "Clean #{t.image_name} image directory"
9
+ }
7
10
 
8
11
  parameter :image_name, :required => true
9
12
  parameter :work_directory, :required => true
10
13
 
11
- def process_arguments(args)
12
- self.name = args[0] if args[0]
13
- end
14
-
15
- def define
16
- desc "Clean #{image_name} image directory"
17
- task name do
18
- rm_rf File.join(work_directory, image_name)
19
- end
14
+ action do |t|
15
+ rm_rf File.join(t.work_directory, t.image_name)
20
16
  end
21
17
  end
22
18
  end
@@ -1,9 +1,12 @@
1
- require_relative '../tasklib'
1
+ require 'rake_factory'
2
2
 
3
3
  module RakeDocker
4
4
  module Tasks
5
- class Prepare < TaskLib
6
- parameter :name, :default => :prepare
5
+ class Prepare < RakeFactory::Task
6
+ default_name :prepare
7
+ default_description ->(t) {
8
+ "Prepare for build of #{t.image_name} image"
9
+ }
7
10
 
8
11
  parameter :image_name, :required => true
9
12
 
@@ -12,39 +15,32 @@ module RakeDocker
12
15
  parameter :copy_spec, :default => []
13
16
  parameter :create_spec, :default => []
14
17
 
15
- def process_arguments(args)
16
- self.name = args[0] if args[0]
17
- end
18
-
19
- def define
20
- desc "Prepare for build of #{image_name} image"
21
- task name do
22
- image_directory = File.join(work_directory, image_name)
23
- mkdir_p image_directory
24
-
25
- copy_spec.each do |entry|
26
- from = entry.is_a?(Hash) ? entry[:from] : entry
27
- to = entry.is_a?(Hash) ?
28
- File.join(image_directory, entry[:to]) :
29
- image_directory
30
-
31
- if File.directory?(from)
32
- mkdir_p to
33
- cp_r from, to
34
- else
35
- cp from, to
36
- end
18
+ action do |t|
19
+ image_directory = File.join(t.work_directory, t.image_name)
20
+ FileUtils.mkdir_p image_directory
21
+
22
+ t.copy_spec.each do |entry|
23
+ from = entry.is_a?(Hash) ? entry[:from] : entry
24
+ to = entry.is_a?(Hash) ?
25
+ File.join(image_directory, entry[:to]) :
26
+ image_directory
27
+
28
+ if File.directory?(from)
29
+ FileUtils.mkdir_p to
30
+ FileUtils.cp_r from, to
31
+ else
32
+ FileUtils.cp from, to
37
33
  end
34
+ end
38
35
 
39
- create_spec.each do |entry|
40
- content = entry[:content]
41
- to = entry[:to]
42
- file = File.join(image_directory, to)
36
+ t.create_spec.each do |entry|
37
+ content = entry[:content]
38
+ to = entry[:to]
39
+ file = File.join(image_directory, to)
43
40
 
44
- mkdir_p(File.dirname(file))
45
- File.open(file, 'w') do |f|
46
- f.write(content)
47
- end
41
+ FileUtils.mkdir_p(File.dirname(file))
42
+ File.open(file, 'w') do |f|
43
+ f.write(content)
48
44
  end
49
45
  end
50
46
  end
@@ -1,12 +1,13 @@
1
+ require 'rake_factory'
1
2
  require 'docker'
2
- require 'ostruct'
3
- require_relative '../tasklib'
4
3
 
5
4
  module RakeDocker
6
5
  module Tasks
7
- class Push < TaskLib
8
- parameter :name, :default => :push
9
- parameter :argument_names, :default => []
6
+ class Push < RakeFactory::Task
7
+ default_name :push
8
+ default_description ->(t) {
9
+ "Push #{t.image_name} image to repository"
10
+ }
10
11
 
11
12
  parameter :image_name, :required => true
12
13
  parameter :repository_url, :required => true
@@ -14,43 +15,19 @@ module RakeDocker
14
15
  parameter :credentials
15
16
  parameter :tags, :required => true
16
17
 
17
- def process_arguments(args)
18
- self.name = args[0] if args[0]
19
- end
20
-
21
- def define
22
- desc "Push #{image_name} image to repository"
23
- task name, argument_names do |_, args|
24
- params = OpenStruct.new(
25
- image_name: image_name,
26
- repository_url: repository_url,
27
- credentials: credentials,
28
- tag: tags
29
- )
30
-
31
- derived_repository_url = repository_url.respond_to?(:call) ?
32
- repository_url.call(*[args, params].slice(0, repository_url.arity)) :
33
- repository_url
34
- derived_credentials = credentials.respond_to?(:call) ?
35
- credentials.call(*[args, params].slice(0, credentials.arity)) :
36
- credentials
37
- derived_tags = tags.respond_to?(:call) ?
38
- tags.call(*[args, params].slice(0, tags.arity)) :
39
- tags
18
+ action do |t|
19
+ Docker.authenticate!(t.credentials) if t.credentials
40
20
 
41
- Docker.authenticate!(derived_credentials) if derived_credentials
42
-
43
- images = Docker::Image.all(filter: derived_repository_url)
44
- if images.empty?
45
- raise RakeDocker::ImageNotFound,
46
- "No image found for repository: '#{derived_repository_url}'"
47
- end
21
+ images = Docker::Image.all(filter: t.repository_url)
22
+ if images.empty?
23
+ raise ImageNotFound,
24
+ "No image found for repository: '#{t.repository_url}'"
25
+ end
48
26
 
49
- image = images.first
50
- derived_tags.each do |tag|
51
- image.push(nil, tag: tag) do |chunk|
52
- DockerOutput.print chunk
53
- end
27
+ image = images.first
28
+ t.tags.each do |tag|
29
+ image.push(nil, tag: tag) do |chunk|
30
+ Output.print chunk
54
31
  end
55
32
  end
56
33
  end
@@ -1,12 +1,13 @@
1
+ require 'rake_factory'
1
2
  require 'docker'
2
- require 'ostruct'
3
- require_relative '../tasklib'
4
3
 
5
4
  module RakeDocker
6
5
  module Tasks
7
- class Tag < TaskLib
8
- parameter :name, :default => :tag
9
- parameter :argument_names, :default => []
6
+ class Tag < RakeFactory::Task
7
+ default_name :tag
8
+ default_description ->(t) {
9
+ "Tag #{t.image_name} image for repository"
10
+ }
10
11
 
11
12
  parameter :image_name, :required => true
12
13
  parameter :repository_name, :required => true
@@ -14,38 +15,19 @@ module RakeDocker
14
15
 
15
16
  parameter :tags, :required => true
16
17
 
17
- def process_arguments(args)
18
- self.name = args[0] if args[0]
19
- end
20
-
21
- def define
22
- desc "Tag #{image_name} image for repository"
23
- task name, argument_names do |_, args|
24
- params = OpenStruct.new(
25
- image_name: image_name,
26
- repository_name: repository_name
27
- )
28
-
29
- derived_repository_url = repository_url.respond_to?(:call) ?
30
- repository_url.call(*[args, params].slice(0, repository_url.arity)) :
31
- repository_url
32
- derived_tags = tags.respond_to?(:call) ?
33
- tags.call(*[args, params].slice(0, tags.arity)) :
34
- tags
35
-
36
- images = Docker::Image.all(filter: repository_name)
37
- if images.empty?
38
- raise RakeDocker::ImageNotFound,
39
- "No image found with name: '#{image_name}'"
40
- end
18
+ action do |t|
19
+ images = Docker::Image.all(filter: t.repository_name)
20
+ if images.empty?
21
+ raise ImageNotFound,
22
+ "No image found with name: '#{t.image_name}'"
23
+ end
41
24
 
42
- image = images.first
25
+ image = images.first
43
26
 
44
- derived_tags.each do |tag|
45
- image.tag(repo: derived_repository_url,
46
- tag: tag,
47
- force: true)
48
- end
27
+ t.tags.each do |tag|
28
+ image.tag(repo: t.repository_url,
29
+ tag: tag,
30
+ force: true)
49
31
  end
50
32
  end
51
33
  end
@@ -1,3 +1,3 @@
1
1
  module RakeDocker
2
- VERSION = '0.23.0'
2
+ VERSION = '0.24.0.pre.1'
3
3
  end
data/rake_docker.gemspec CHANGED
@@ -21,15 +21,16 @@ Gem::Specification.new do |spec|
21
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
22
  spec.require_paths = ['lib']
23
23
 
24
- spec.required_ruby_version = '>= 2.3.8'
24
+ spec.required_ruby_version = '>= 2.6'
25
25
 
26
26
  spec.add_dependency 'docker-api', '~> 1.34'
27
+ spec.add_dependency 'rake_factory', '~> 0.15'
27
28
  spec.add_dependency 'aws-sdk-ecr', '~> 1.2'
28
29
  spec.add_dependency 'colored2', '~> 3.1'
29
30
 
30
- spec.add_development_dependency 'bundler', '~> 1.16'
31
- spec.add_development_dependency 'rake', '~> 12.3'
32
- spec.add_development_dependency 'rspec', '~> 3.8'
31
+ spec.add_development_dependency 'bundler', '~> 2.0'
32
+ spec.add_development_dependency 'rake', '~> 13.0'
33
+ spec.add_development_dependency 'rspec', '~> 3.9'
33
34
  spec.add_development_dependency 'gem-release', '~> 2.0'
34
35
  spec.add_development_dependency 'activesupport', '~> 5.2'
35
36
  spec.add_development_dependency 'memfs', '~> 1.0'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rake_docker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.23.0
4
+ version: 0.24.0.pre.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toby Clemson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-05-26 00:00:00.000000000 Z
11
+ date: 2020-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docker-api
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.34'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake_factory
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.15'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.15'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: aws-sdk-ecr
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -58,42 +72,42 @@ dependencies:
58
72
  requirements:
59
73
  - - "~>"
60
74
  - !ruby/object:Gem::Version
61
- version: '1.16'
75
+ version: '2.0'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
80
  - - "~>"
67
81
  - !ruby/object:Gem::Version
68
- version: '1.16'
82
+ version: '2.0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: rake
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
87
  - - "~>"
74
88
  - !ruby/object:Gem::Version
75
- version: '12.3'
89
+ version: '13.0'
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
94
  - - "~>"
81
95
  - !ruby/object:Gem::Version
82
- version: '12.3'
96
+ version: '13.0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: rspec
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
101
  - - "~>"
88
102
  - !ruby/object:Gem::Version
89
- version: '3.8'
103
+ version: '3.9'
90
104
  type: :development
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
108
  - - "~>"
95
109
  - !ruby/object:Gem::Version
96
- version: '3.8'
110
+ version: '3.9'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: gem-release
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -185,14 +199,14 @@ files:
185
199
  - config/secrets/ci/ssh.public
186
200
  - config/secrets/rubygems/credentials
187
201
  - go
188
- - lib/docker_output.rb
189
202
  - lib/rake_docker.rb
190
203
  - lib/rake_docker/authentication.rb
191
204
  - lib/rake_docker/authentication/ecr.rb
192
205
  - lib/rake_docker/exceptions.rb
193
- - lib/rake_docker/tasklib.rb
206
+ - lib/rake_docker/output.rb
207
+ - lib/rake_docker/task_sets.rb
208
+ - lib/rake_docker/task_sets/all.rb
194
209
  - lib/rake_docker/tasks.rb
195
- - lib/rake_docker/tasks/all.rb
196
210
  - lib/rake_docker/tasks/build.rb
197
211
  - lib/rake_docker/tasks/clean.rb
198
212
  - lib/rake_docker/tasks/prepare.rb
@@ -219,14 +233,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
219
233
  requirements:
220
234
  - - ">="
221
235
  - !ruby/object:Gem::Version
222
- version: 2.3.8
236
+ version: '2.6'
223
237
  required_rubygems_version: !ruby/object:Gem::Requirement
224
238
  requirements:
225
- - - ">="
239
+ - - ">"
226
240
  - !ruby/object:Gem::Version
227
- version: '0'
241
+ version: 1.3.1
228
242
  requirements: []
229
- rubygems_version: 3.0.3
243
+ rubygems_version: 3.0.1
230
244
  signing_key:
231
245
  specification_version: 4
232
246
  summary: Rake tasks for managing images and containers.
data/lib/docker_output.rb DELETED
@@ -1,47 +0,0 @@
1
- require 'json'
2
- require 'colored2'
3
-
4
- module DockerOutput
5
- def self.parse(chunk)
6
- chunk.each_line do |line|
7
- yield self.parse_line(line)
8
- end
9
- end
10
-
11
- def self.parse_line(line)
12
- begin
13
- json = JSON.parse(line.strip)
14
- rescue JSON::ParserError
15
- return line
16
- end
17
-
18
- # Skip progress and aux as they are covered by other status messages
19
- return '' if json['progress'] && json['status']
20
- return '' if json['aux']
21
-
22
- # Return error flag as a second result
23
- return [json['error'], true] if json['error']
24
-
25
- return json['stream'] if json['stream']
26
-
27
- if json['status']
28
- if json['id']
29
- return json['id'] + ': ' + json['status'] + "\n"
30
- else
31
- return json['status'] + "\n"
32
- end
33
- end
34
-
35
- return line # Nothing else matches
36
- end
37
-
38
- def self.print(chunk)
39
- self.parse(chunk) do |text, is_error|
40
- if is_error
41
- $stdout.print text.red + "\n"
42
- raise text
43
- end
44
- $stdout.print text unless text.empty?
45
- end
46
- end
47
- end
@@ -1,98 +0,0 @@
1
- require 'rake/tasklib'
2
- require_relative 'exceptions'
3
-
4
- module RakeDocker
5
- class TaskLib < ::Rake::TaskLib
6
- class << self
7
- def parameter_definitions
8
- @parameter_definitions ||= {}
9
- end
10
-
11
- def parameter(name, options = {})
12
- parameter_definition = ParameterDefinition.new(
13
- name, options[:default], options[:required])
14
- name = parameter_definition.name
15
-
16
- attr_accessor(name)
17
-
18
- parameter_definitions[name] = parameter_definition
19
- end
20
-
21
- def setup_defaults_for(instance)
22
- parameter_definitions.values.each do |parameter_definition|
23
- parameter_definition.apply_default_to(instance)
24
- end
25
- end
26
-
27
- def check_required_for(instance)
28
- dissatisfied = parameter_definitions.values.reject do |definition|
29
- definition.satisfied_by?(instance)
30
- end
31
- unless dissatisfied.empty?
32
- names = dissatisfied.map(&:name)
33
- raise RequiredParameterUnset,
34
- "Required parameter#{names.length > 1 ? 's' : ''} #{names.join(',')} unset."
35
- end
36
- end
37
- end
38
-
39
- def initialize(*args, &block)
40
- setup_defaults
41
- process_arguments(args)
42
- process_block(block)
43
- check_required
44
- define
45
- end
46
-
47
- def setup_defaults
48
- self.class.setup_defaults_for(self)
49
- end
50
-
51
- def process_arguments(_)
52
- end
53
-
54
- def process_block(block)
55
- block.call(self) if block
56
- end
57
-
58
- def check_required
59
- self.class.check_required_for(self)
60
- end
61
-
62
- def define
63
- end
64
-
65
- private
66
-
67
- class ParameterDefinition
68
- attr_reader :name
69
-
70
- def initialize(name, default = nil, required = false)
71
- @name = name.to_sym
72
- @default = default
73
- @required = required
74
- end
75
-
76
- def writer_method
77
- "#{name}="
78
- end
79
-
80
- def reader_method
81
- name
82
- end
83
-
84
- def apply_default_to(instance)
85
- instance.__send__(writer_method, @default) if @default
86
- end
87
-
88
- def dissatisfied_by?(instance)
89
- value = instance.__send__(reader_method)
90
- @required && value.nil?
91
- end
92
-
93
- def satisfied_by?(instance)
94
- !dissatisfied_by?(instance)
95
- end
96
- end
97
- end
98
- end
@@ -1,93 +0,0 @@
1
- require 'docker'
2
- require_relative 'clean'
3
- require_relative 'prepare'
4
- require_relative 'build'
5
- require_relative 'tag'
6
- require_relative 'push'
7
- require_relative '../tasklib'
8
-
9
- module RakeDocker
10
- module Tasks
11
- class All < TaskLib
12
- parameter :containing_namespace
13
-
14
- parameter :image_name, :required => true
15
- parameter :repository_name, :required => true
16
- parameter :repository_url, :required => true
17
-
18
- parameter :work_directory, :required => true
19
-
20
- parameter :copy_spec, :default => []
21
- parameter :create_spec, :default => []
22
-
23
- parameter :argument_names, :default => []
24
-
25
- parameter :tags, :required => true
26
-
27
- parameter :credentials
28
-
29
- parameter :build_args
30
-
31
- parameter :clean_task_name, :default => :clean
32
- parameter :prepare_task_name, :default => :prepare
33
- parameter :build_task_name, :default => :build
34
- parameter :tag_task_name, :default => :tag
35
- parameter :push_task_name, :default => :push
36
-
37
- alias namespace= containing_namespace=
38
-
39
- def define
40
- if containing_namespace
41
- namespace containing_namespace do
42
- define_tasks
43
- end
44
- else
45
- define_tasks
46
- end
47
- end
48
-
49
- private
50
-
51
- def define_tasks
52
- Clean.new do |t|
53
- t.name = clean_task_name
54
- t.image_name = image_name
55
- t.work_directory = work_directory
56
- end
57
- Prepare.new do |t|
58
- t.name = prepare_task_name
59
- t.image_name = image_name
60
- t.work_directory = work_directory
61
- t.copy_spec = copy_spec
62
- t.create_spec = create_spec
63
- end
64
- Build.new do |t|
65
- t.name = build_task_name
66
- t.argument_names = argument_names
67
- t.image_name = image_name
68
- t.repository_name = repository_name
69
- t.work_directory = work_directory
70
- t.build_args = build_args
71
- t.credentials = credentials
72
- t.prepare_task = prepare_task_name
73
- end
74
- Tag.new do |t|
75
- t.name = tag_task_name
76
- t.argument_names = argument_names
77
- t.image_name = image_name
78
- t.repository_name = repository_name
79
- t.repository_url = repository_url
80
- t.tags = tags
81
- end
82
- Push.new do |t|
83
- t.name = push_task_name
84
- t.argument_names = argument_names
85
- t.image_name = image_name
86
- t.repository_url = repository_url
87
- t.tags = tags
88
- t.credentials = credentials
89
- end
90
- end
91
- end
92
- end
93
- end