docker-shaball 0.1.1 → 0.2.0

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: efbb7a3444628460b40193c085ff5fd5e8fc39bd
4
- data.tar.gz: d116594e8a79c88892f45c4eb4faec62774c5733
3
+ metadata.gz: e31baf5f571efcbebcbbefc31e88501a6a36cfed
4
+ data.tar.gz: 18c303957629f12c899d24af82321d76461099ce
5
5
  SHA512:
6
- metadata.gz: 2df782b032af84e7db43269371cd37d79d2fd6d495c94acc911dbed82d00a73c2eef0c8e269e56d14c56c6f834487b00bb24ef27e70d934c3c13ba601e5a75e0
7
- data.tar.gz: 167623a824fc1071f5c7bfbee8ac90d2e543b39cdd2d5d6d10b631cd88146a05f2e59fbf8600540cb0ae8371d12570f649466fc1f0713b77a50c7a10f66bd783
6
+ metadata.gz: 5fccd067d031187b13e15bb3b78d251a531463387e657969546d2e57a2df271832bfc1c8510cf06e51683ee278c5c0274fc2d3668e902aa4cd93e026c10124f9
7
+ data.tar.gz: 3094e029576b11e54c360ad078c300096ddbd63b3ae11a6d089e2ca836925b4e43c9688201eb7d9644cbe0cc4008f4e6f6090dd4c4481f3432802c3a3bd52ebb
data/.rubocop.yml ADDED
@@ -0,0 +1,50 @@
1
+ Eval:
2
+ Exclude:
3
+ - "Rakefile"
4
+
5
+ Metrics/AbcSize:
6
+ Enabled: false
7
+
8
+ Metrics/LineLength:
9
+ Max: 120
10
+
11
+ Metrics/MethodLength:
12
+ Max: 30
13
+
14
+ Style/AsciiIdentifiers
15
+ Enabled: false
16
+
17
+ Style/ClassAndModuleChildren:
18
+ EnforcedStyle: nested
19
+ Exclude:
20
+ - "spec/**/*"
21
+
22
+ Style/Documentation:
23
+ Exclude:
24
+ - "spec/**/*"
25
+
26
+ Style/EmptyLinesAroundBlockBody:
27
+ Enabled: false
28
+
29
+ Style/EmptyLinesAroundClassBody:
30
+ EnforcedStyle: empty_lines
31
+
32
+ Style/EmptyLinesAroundModuleBody:
33
+ Enabled: false
34
+
35
+ Style/Encoding:
36
+ EnforcedStyle: when_needed
37
+ Enabled: true
38
+
39
+ Style/FileName:
40
+ Exclude:
41
+ - "bin/*"
42
+
43
+ Style/HashSyntax:
44
+ EnforcedStyle: hash_rockets
45
+
46
+ Style/StringLiterals:
47
+ EnforcedStyle: double_quotes
48
+
49
+ Style/WordArray:
50
+ Enabled: false
data/bin/docker-shaball CHANGED
@@ -2,12 +2,14 @@
2
2
 
3
3
  require "clamp"
4
4
  require "digest/sha1"
5
+ require "fileutils"
5
6
 
6
7
  Clamp do
7
8
 
8
9
  self.description = "Bundle docker images into a tar-ball, with a unique name based on content"
9
10
 
10
11
  option "--pull", :flag, "pull the named images first"
12
+ option "--force", :flag, "force re-generation of output file"
11
13
 
12
14
  option "--manifest", :flag, "just print the image manifest"
13
15
 
@@ -16,7 +18,7 @@ Clamp do
16
18
  def execute
17
19
  if pull?
18
20
  image_names.each do |name|
19
- system("docker pull #{name}")
21
+ system("docker pull #{name} > /dev/null")
20
22
  signal_error("docker pull failed") unless $?.success?
21
23
  end
22
24
  end
@@ -26,23 +28,27 @@ Clamp do
26
28
  end
27
29
  manifest_checksum = Digest::SHA1.hexdigest(image_manifest)
28
30
  output_file_name = "#{manifest_checksum}.tar.gz"
29
-
30
- save_images(image_names, output_file_name)
31
+ unless !force? && File.exist?(output_file_name)
32
+ save_images(image_names, output_file_name)
33
+ end
31
34
  puts output_file_name
32
35
  end
33
36
 
34
37
  private
35
38
 
36
39
  def save_images(image_names, output_file_name)
37
- r,w = IO.pipe
38
- save = spawn("docker save #{image_names.join(' ')}", out: w)
39
- gzip = spawn("gzip", in: r, out: [output_file_name, 'w'])
40
+ FileUtils.safe_unlink(output_file_name)
41
+ tmp_file_name = "#{output_file_name}.tmp"
42
+ r, w = IO.pipe
43
+ save = spawn("docker save #{image_names.join(' ')}", :out => w)
44
+ gzip = spawn("gzip", :in => r, :out => [tmp_file_name, "w"])
40
45
  r.close
41
46
  w.close
42
47
  Process.wait save
43
48
  signal_error("docker save failed") unless $?.success?
44
49
  Process.wait gzip
45
50
  signal_error("gzip failed") unless $?.success?
51
+ File.rename(tmp_file_name, output_file_name)
46
52
  end
47
53
 
48
54
  def image_names
@@ -53,7 +59,7 @@ Clamp do
53
59
  end
54
60
 
55
61
  def image_manifest
56
- inspect_output = `docker inspect -f '{{ .Config.Image }}' #{image_names.join(' ')}`
62
+ inspect_output = `docker inspect -f '{{ .Config.Image }}' #{image_names.join(" ")}`
57
63
  signal_error("docker inspect returned error") unless $?.success?
58
64
  image_ids = inspect_output.lines.map(&:strip)
59
65
  image_names.zip(image_ids).map do |image_name_and_id|
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
  Gem::Specification.new do |spec|
6
6
 
7
7
  spec.name = "docker-shaball"
8
- spec.version = "0.1.1"
8
+ spec.version = "0.2.0"
9
9
  spec.authors = ["Mike Williams", "Luke Carter-Key"]
10
10
  spec.email = ["mdub@dogbiscuit.org", "luke.carterkey@gmail.com"]
11
11
  spec.summary = %q{Create a tar-ball containing some Docker images}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docker-shaball
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Williams
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-07-24 00:00:00.000000000 Z
12
+ date: 2015-07-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: clamp
@@ -63,6 +63,7 @@ extensions: []
63
63
  extra_rdoc_files: []
64
64
  files:
65
65
  - ".gitignore"
66
+ - ".rubocop.yml"
66
67
  - Gemfile
67
68
  - README.md
68
69
  - Rakefile
@@ -88,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
89
  version: '0'
89
90
  requirements: []
90
91
  rubyforge_project:
91
- rubygems_version: 2.4.8
92
+ rubygems_version: 2.4.5
92
93
  signing_key:
93
94
  specification_version: 4
94
95
  summary: Create a tar-ball containing some Docker images