rake_docker 0.5.0 → 0.6.0

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
  SHA1:
3
- metadata.gz: 1758f497dafdfe7523fcaab8e6c9cb25ed5c4107
4
- data.tar.gz: f75d58365df1f21e712d527b090c89685ebbeebf
3
+ metadata.gz: 6e3674a7b2cd6f279f83435aab1c4b8af38dc207
4
+ data.tar.gz: 71b1f0919e623638154d3c3106dc66f28a3841c1
5
5
  SHA512:
6
- metadata.gz: cf33f61e14e730650bfb8cd91d350a93e96463eac1a05103c908ea56bddaf55e260499ff1f45dc94884f5cb3f876d1e2bcd3b958096430dfe49393fa420f45be
7
- data.tar.gz: 81d5421db3ece7b6d983fed38ab69b67004ccecf629d95bec80fa8fb4dc9868e7136087b7844db46e3da4f0e9f806316a8387d86ccc14e60a12ff09f1334e354
6
+ metadata.gz: 363475f69e80d9f97a602ccba11efef84b32c476d255072786682af2ccc93946eabc836980bc92511b3a5c86c8f228e39f10954d8616a9d29af7c859f600bbaa
7
+ data.tar.gz: 1d6d929f4eaaca576ec5f9d5a221549aa93e21a53971bc0762ed132c4ef09f4d46bd89c0d12f2ac159692089324a80e0927d7523a69f65e0d2673f342f7c3fda
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rake_docker (0.5.0)
4
+ rake_docker (0.6.0)
5
5
  docker-api (~> 1.33)
6
6
 
7
7
  GEM
@@ -0,0 +1,57 @@
1
+ require 'docker'
2
+ require_relative '../tasklib'
3
+
4
+ module RakeDocker
5
+ module Tasks
6
+ class Push < TaskLib
7
+ parameter :name, :default => :push
8
+
9
+ parameter :image_name, :required => true
10
+ parameter :repository_url, :required => true
11
+
12
+ parameter :credentials
13
+ parameter :tags, :required => true
14
+
15
+ def process_arguments(args)
16
+ self.name = args[0] if args[0]
17
+ end
18
+
19
+ def define
20
+ desc "Push #{image_name} image to repository"
21
+ task name do
22
+ params = OpenStruct.new({
23
+ image_name: image_name,
24
+ repository_url: repository_url,
25
+ credentials: credentials,
26
+ tag: tags
27
+ })
28
+
29
+ derived_repository_url = repository_url.respond_to?(:call) ?
30
+ repository_url.call(*[params].slice(0, repository_url.arity)) :
31
+ repository_url
32
+ derived_credentials = credentials.respond_to?(:call) ?
33
+ credentials.call(*[params].slice(0, credentials.arity)) :
34
+ credentials
35
+ derived_tags = tags.respond_to?(:call) ?
36
+ tags.call(*[params].slice(0, tags.arity)) :
37
+ tags
38
+
39
+ Docker.authenticate!(derived_credentials) if derived_credentials
40
+
41
+ images = Docker::Image.all(filter: derived_repository_url)
42
+ if images.empty?
43
+ raise RakeDocker::ImageNotFound,
44
+ "No image found for repository: '#{derived_repository_url}'"
45
+ end
46
+
47
+ image = images.first
48
+ derived_tags.each do |tag|
49
+ image.push(nil, tag: tag) do |chunk|
50
+ $stdout.puts chunk
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -10,8 +10,7 @@ module RakeDocker
10
10
  parameter :repository_name, :required => true
11
11
  parameter :repository_url, :required => true
12
12
 
13
- parameter :tag
14
- parameter :tag_as_latest, :default => false
13
+ parameter :tags, :required => true
15
14
 
16
15
  def process_arguments(args)
17
16
  self.name = args[0] if args[0]
@@ -28,9 +27,9 @@ module RakeDocker
28
27
  derived_repository_url = repository_url.respond_to?(:call) ?
29
28
  repository_url.call(*[params].slice(0, repository_url.arity)) :
30
29
  repository_url
31
- derived_tag = tag.respond_to?(:call) ?
32
- tag.call(*[params].slice(0, tag.arity)) :
33
- tag
30
+ derived_tags = tags.respond_to?(:call) ?
31
+ tags.call(*[params].slice(0, tags.arity)) :
32
+ tags
34
33
 
35
34
  images = Docker::Image.all(filter: repository_name)
36
35
  if images.empty?
@@ -39,12 +38,12 @@ module RakeDocker
39
38
  end
40
39
 
41
40
  image = images.first
42
- image.tag(repo: derived_repository_url,
43
- tag: derived_tag,
44
- force: true) if derived_tag
45
- image.tag(repo: derived_repository_url,
46
- tag: 'latest',
47
- force: true) if tag_as_latest
41
+
42
+ derived_tags.each do |tag|
43
+ image.tag(repo: derived_repository_url,
44
+ tag: tag,
45
+ force: true)
46
+ end
48
47
  end
49
48
  end
50
49
  end
@@ -1,4 +1,5 @@
1
1
  require_relative 'tasks/clean'
2
2
  require_relative 'tasks/prepare'
3
3
  require_relative 'tasks/build'
4
- require_relative 'tasks/tag'
4
+ require_relative 'tasks/tag'
5
+ require_relative 'tasks/push'
@@ -1,3 +1,3 @@
1
1
  module RakeDocker
2
- VERSION = '0.5.0'
2
+ VERSION = '0.6.0'
3
3
  end
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.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toby Clemson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-07-04 00:00:00.000000000 Z
11
+ date: 2017-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docker-api
@@ -148,6 +148,7 @@ files:
148
148
  - lib/rake_docker/tasks/build.rb
149
149
  - lib/rake_docker/tasks/clean.rb
150
150
  - lib/rake_docker/tasks/prepare.rb
151
+ - lib/rake_docker/tasks/push.rb
151
152
  - lib/rake_docker/tasks/tag.rb
152
153
  - lib/rake_docker/version.rb
153
154
  - rake_docker.gemspec