rake_docker 0.4.0 → 0.5.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: 6769a28f711f605cb756ef1773272de189786d6c
4
- data.tar.gz: 84e5ce8d0a1802b6c2c36b0ed121e179495671a7
3
+ metadata.gz: 1758f497dafdfe7523fcaab8e6c9cb25ed5c4107
4
+ data.tar.gz: f75d58365df1f21e712d527b090c89685ebbeebf
5
5
  SHA512:
6
- metadata.gz: 1f3b58dcddce17be6dacd323cf267b8e69cb26f5ff0c87f3b6c0df1dbbc9e6d688d1177db26c3e6cec04524b5b3aa46fc6fb313c967ea839c93665188d6ff7df
7
- data.tar.gz: f46f367db858bfce8ae440f38adfea0d95cefb0fe8cda7ca822aa7d63b2d5ec8e35c36eb11949da098da8f78d93b0b6b415db856217f3c41313c0b3751f5371c
6
+ metadata.gz: cf33f61e14e730650bfb8cd91d350a93e96463eac1a05103c908ea56bddaf55e260499ff1f45dc94884f5cb3f876d1e2bcd3b958096430dfe49393fa420f45be
7
+ data.tar.gz: 81d5421db3ece7b6d983fed38ab69b67004ccecf629d95bec80fa8fb4dc9868e7136087b7844db46e3da4f0e9f806316a8387d86ccc14e60a12ff09f1334e354
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rake_docker (0.4.0)
4
+ rake_docker (0.5.0)
5
5
  docker-api (~> 1.33)
6
6
 
7
7
  GEM
@@ -1,4 +1,7 @@
1
1
  module RakeDocker
2
2
  class RequiredParameterUnset < ::StandardError
3
3
  end
4
+
5
+ class ImageNotFound < ::StandardError
6
+ end
4
7
  end
@@ -1,2 +1,4 @@
1
+ require_relative 'tasks/clean'
1
2
  require_relative 'tasks/prepare'
2
- require_relative 'tasks/build'
3
+ require_relative 'tasks/build'
4
+ require_relative 'tasks/tag'
@@ -0,0 +1,23 @@
1
+ require_relative '../tasklib'
2
+
3
+ module RakeDocker
4
+ module Tasks
5
+ class Clean < TaskLib
6
+ parameter :name, :default => :clean
7
+
8
+ parameter :image_name, :required => true
9
+ parameter :work_directory, :required => true
10
+
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
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,52 @@
1
+ require 'docker'
2
+ require_relative '../tasklib'
3
+
4
+ module RakeDocker
5
+ module Tasks
6
+ class Tag < TaskLib
7
+ parameter :name, :default => :tag
8
+
9
+ parameter :image_name, :required => true
10
+ parameter :repository_name, :required => true
11
+ parameter :repository_url, :required => true
12
+
13
+ parameter :tag
14
+ parameter :tag_as_latest, :default => false
15
+
16
+ def process_arguments(args)
17
+ self.name = args[0] if args[0]
18
+ end
19
+
20
+ def define
21
+ desc "Tag #{image_name} image for repository"
22
+ task name do
23
+ params = OpenStruct.new({
24
+ image_name: image_name,
25
+ repository_name: repository_name
26
+ })
27
+
28
+ derived_repository_url = repository_url.respond_to?(:call) ?
29
+ repository_url.call(*[params].slice(0, repository_url.arity)) :
30
+ repository_url
31
+ derived_tag = tag.respond_to?(:call) ?
32
+ tag.call(*[params].slice(0, tag.arity)) :
33
+ tag
34
+
35
+ images = Docker::Image.all(filter: repository_name)
36
+ if images.empty?
37
+ raise RakeDocker::ImageNotFound,
38
+ "No image found with name: '#{image_name}'"
39
+ end
40
+
41
+ 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
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -1,3 +1,3 @@
1
1
  module RakeDocker
2
- VERSION = '0.4.0'
2
+ VERSION = '0.5.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.4.0
4
+ version: 0.5.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-02 00:00:00.000000000 Z
11
+ date: 2017-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docker-api
@@ -146,7 +146,9 @@ files:
146
146
  - lib/rake_docker/tasklib.rb
147
147
  - lib/rake_docker/tasks.rb
148
148
  - lib/rake_docker/tasks/build.rb
149
+ - lib/rake_docker/tasks/clean.rb
149
150
  - lib/rake_docker/tasks/prepare.rb
151
+ - lib/rake_docker/tasks/tag.rb
150
152
  - lib/rake_docker/version.rb
151
153
  - rake_docker.gemspec
152
154
  homepage: https://github.com/tobyclemson/rake_docker