dockly 1.13.0 → 2.0.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.
@@ -17,7 +17,7 @@ describe Dockly::BashBuilder do
17
17
  output = subject.get_and_install_deb(s3_url, deb_path)
18
18
  expect(output).to include(s3_url)
19
19
  expect(output).to include(deb_path)
20
- expect(output).to include("s3cmd -f get")
20
+ expect(output).to include("aws s3 cp --quiet")
21
21
  expect(output).to include("dpkg -i")
22
22
  end
23
23
  end
@@ -56,7 +56,7 @@ describe Dockly::BashBuilder do
56
56
  expect(output).to include(base_image)
57
57
  expect(output).to include(diff_image)
58
58
  expect(output).to include("cat \"#{diff_image}\"")
59
- expect(output).to include("s3cmd -f get")
59
+ expect(output).to include("aws s3 cp --quiet")
60
60
  expect(output).to include("docker import -")
61
61
  end
62
62
  end
@@ -67,7 +67,7 @@ describe Dockly::BashBuilder do
67
67
  output = subject.s3_docker_import(s3_url)
68
68
  expect(output).to include(s3_url)
69
69
  expect(output).to include("gunzip -c")
70
- expect(output).to include("s3cmd -f get")
70
+ expect(output).to include("aws s3 cp --quiet")
71
71
  expect(output).to include("docker import -")
72
72
  end
73
73
  end
@@ -83,7 +83,7 @@ describe Dockly::BashBuilder do
83
83
  expect(output).to include("$(($size - 1024))") # compute file size
84
84
  expect(output).to include("head -c $head_size")
85
85
  expect(output).to include("gunzip")
86
- expect(output).to include("s3cmd -f get")
86
+ expect(output).to include("aws s3 cp --quiet")
87
87
  expect(output).to include("docker import -")
88
88
  end
89
89
  end
@@ -7,7 +7,7 @@ describe Dockly::BuildCache::Docker, :docker do
7
7
  git_archive '/app'
8
8
  end
9
9
  end
10
- let(:image) { ::Docker::Image.build('from ubuntu:14.04') }
10
+ let(:image) { ::Docker::Image.build('from base') }
11
11
 
12
12
  before do
13
13
  build_cache.s3_bucket 'lol'
@@ -46,7 +46,7 @@ describe Dockly::BuildCache::Docker, :docker do
46
46
  it "does not have the file lol" do
47
47
  i = build_cache.execute!
48
48
  output = ""
49
- i.run('ls').attach(logs: true) { |source,chunk| output += chunk }
49
+ i.run('ls').attach { |source,chunk| output += chunk }
50
50
  output.should_not include('lol')
51
51
  end
52
52
  end
@@ -60,8 +60,8 @@ describe Dockly::BuildCache::Docker, :docker do
60
60
 
61
61
  it "does have the file lol" do
62
62
  i = build_cache.execute!
63
- output = i.run('ls /').attach(stdout: true, logs: true)
64
- expect(output.first.grep(/lol/)).to_not be_empty
63
+ output = i.run('ls /').attach(:stdout => true)
64
+ output.first.first.lines.map(&:chomp).should include('lol')
65
65
  end
66
66
  end
67
67
  end
@@ -75,7 +75,7 @@ describe Dockly::BuildCache::Docker, :docker do
75
75
  it "does have the file lol" do
76
76
  i = build_cache.run_build
77
77
  output = ""
78
- i.run('ls').attach(logs: true) { |source,chunk| output += chunk }
78
+ i.run('ls').attach { |source,chunk| output += chunk }
79
79
  output.should include('lol')
80
80
  end
81
81
  end
@@ -100,7 +100,7 @@ describe Dockly::BuildCache::Docker, :docker do
100
100
 
101
101
  describe '#hash_output' do
102
102
  let(:output) {
103
- "b458e7b28b9bc2d04bd5a3fd0f8d777e /etc/vim/vimrc"
103
+ "682aa2a07693cc27756eee9751db3903 /etc/vim/vimrc"
104
104
  }
105
105
 
106
106
  context "when hash command returns successfully" do
@@ -127,7 +127,7 @@ describe Dockly::BuildCache::Docker, :docker do
127
127
  end
128
128
 
129
129
  describe '#copy_output_dir' do
130
- let(:container) { Docker::Container.create('Image' => 'ubuntu:14.04', 'Cmd' => %w[true]) }
130
+ let(:container) { Docker::Container.create('Image' => 'base', 'Cmd' => %w[true]) }
131
131
  let(:file) { build_cache.copy_output_dir(container) }
132
132
  let(:hash) { 'this_really_unique_hash' }
133
133
  let(:path) { file.path }
@@ -156,7 +156,7 @@ describe Dockly::BuildCache::Docker, :docker do
156
156
  context "when parameter command returns successfully" do
157
157
  let(:command) { "uname -r" }
158
158
  it 'returns the output of the parameter_command' do
159
- expect(build_cache.parameter_output(command)).to match(/\A3\.\d{2}\.\d-\d{1,2}-\w+\Z/)
159
+ expect(build_cache.parameter_output(command)).to match(/\A3\.\d{2}\.\d-\d-ARCH\Z/)
160
160
  end
161
161
  end
162
162
 
@@ -25,36 +25,23 @@ describe Dockly::Deb do
25
25
  end
26
26
  end
27
27
 
28
- context 'when it has foreman exports' do
29
- let(:contents) { `dpkg --contents #{filename}` }
30
-
28
+ context 'when it has a foreman export' do
31
29
  before do
32
30
  subject.foreman do
33
- name 'systemd-foreman'
34
- build_dir 'build/foreman'
31
+ name 'foreman'
35
32
  init_dir '/etc/systemd/system'
36
- procfile File.join(File.dirname(__FILE__), '..', 'fixtures', 'Procfile')
37
- user 'root'
38
- type 'systemd'
39
- prefix '/bin/sh'
40
- end
41
-
42
- subject.foreman do
43
- name 'upstart-foreman'
44
33
  build_dir 'build/foreman'
45
- init_dir '/etc/systemd/system'
46
34
  procfile File.join(File.dirname(__FILE__), '..', 'fixtures', 'Procfile')
47
35
  user 'root'
48
- type 'upstart'
36
+ type 'systemd'
49
37
  prefix '/bin/sh'
50
38
  end
51
-
52
- subject.create_package!
53
39
  end
54
40
 
55
- it 'exports the foreman to the deb', :cur do
56
- expect(contents).to match(/upstart-foreman/)
57
- expect(contents).to match(/systemd-foreman/)
41
+ it 'export the foreman to the deb' do
42
+ subject.create_package!
43
+ `dpkg --contents #{filename}`
44
+ .lines.grep(/foreman/).should_not be_empty
58
45
  end
59
46
  end
60
47
 
@@ -64,18 +51,11 @@ describe Dockly::Deb do
64
51
  name 'deb_test'
65
52
  import 'https://s3.amazonaws.com/swipely-pub/docker-export-ubuntu-latest.tgz'
66
53
  git_archive '.'
67
- build 'RUN touch /deb_worked'
54
+ build 'touch /deb_worked'
68
55
  build_dir 'build/docker'
69
56
  end
70
57
  end
71
58
 
72
- after do
73
- image = ::Docker::Image.all.find do |image|
74
- image.info['RepoTags'].include?('deb_test:latest')
75
- end
76
- image.remove if image
77
- end
78
-
79
59
  it 'builds the docker image and adds it to the deb' do
80
60
  subject.create_package!
81
61
  `dpkg --contents #{filename}`
@@ -89,25 +69,18 @@ describe Dockly::Deb do
89
69
  name 'deb_test'
90
70
  import 'https://s3.amazonaws.com/swipely-pub/docker-export-ubuntu-latest.tgz'
91
71
  git_archive '.'
92
- build 'RUN touch /deb_worked'
72
+ build 'touch /deb_worked'
93
73
  build_dir 'build/docker'
94
74
 
95
75
  registry :test_docker_registry do
96
76
  auth_config_file '/etc/docker/.dockercfg'
97
- username ENV['DOCKER_USER']
98
- email ENV['DOCKER_EMAIL']
99
- password ENV['DOCKER_PASS']
77
+ username 'tlunter'
78
+ email 'tlunter@gmail.com'
79
+ password '******'
100
80
  end
101
81
  end
102
82
  end
103
83
 
104
- after do
105
- image = ::Docker::Image.all.find do |image|
106
- image.info['RepoTags'].include?("#{ENV['DOCKER_USER']}/deb_test:latest")
107
- end
108
- image.remove if image
109
- end
110
-
111
84
  it 'builds the docker image and adds it to the deb' do
112
85
  subject.create_package!
113
86
  `dpkg --contents #{filename}`
@@ -166,15 +139,6 @@ describe Dockly::Deb do
166
139
  subject.create_package!
167
140
  expect(`dpkg --contents #{filename}`).to include("dockly-startup.sh")
168
141
  end
169
-
170
- context 'when package_startup_script is false' do
171
- before { subject.package_startup_script(false) }
172
-
173
- it 'does not place a startup script in the package' do
174
- subject.create_package!
175
- expect(`dpkg --contents #{filename}`).to_not include("dockly-startup.sh")
176
- end
177
- end
178
142
  end
179
143
 
180
144
  describe '#exists?' do
@@ -64,16 +64,7 @@ describe Dockly::Docker do
64
64
  end
65
65
 
66
66
  describe '#import_base', :docker do
67
- let(:images) { [] }
68
- let(:docker_file_s3) { 'https://s3.amazonaws.com/swipely-pub/docker-export-ubuntu-latest.tgz' }
69
67
  let(:docker_file) { 'docker-export-ubuntu-latest.tar.gz' }
70
- let(:container) { Docker::Container.create('Image' => images.last.id, 'Cmd' => ['ls', '-1', '/']) }
71
- let(:output) { container.tap(&:start).attach(logs: true) }
72
-
73
- after do
74
- container.tap(&:wait).remove
75
- images.last.remove
76
- end
77
68
 
78
69
  # TODO: since we used to run this w/ Vagrant, we put it all together; break it up
79
70
  it 'works' do
@@ -81,21 +72,27 @@ describe Dockly::Docker do
81
72
  subject.tag 'my-app'
82
73
  unless File.exist?(docker_file)
83
74
  File.open(docker_file, 'wb') do |file|
84
- Excon.get(docker_file_s3, response_block: lambda { |chunk, _, _| file.write(chunk) })
75
+ Excon.get('https://s3.amazonaws.com/swipely-pub/docker-export-ubuntu-latest.tgz',
76
+ :response_block => lambda { |chunk, _, _| file.write(chunk) })
85
77
  end
86
78
  end
87
- images << subject.import_base(subject.ensure_tar(docker_file))
88
- expect(images.last).to_not be_nil
89
- expect(images.last.id).to_not be_nil
79
+ image = subject.import_base(subject.ensure_tar(docker_file))
80
+ image.should_not be_nil
81
+ image.id.should_not be_nil
90
82
 
91
83
  # it 'builds'
92
84
  subject.build "run touch /lol"
93
- images << subject.build_image(images.last)
94
- expect(output[0].grep(/lol/)).to_not be_empty
85
+ image = subject.build_image(image)
86
+ container = Docker::Container.create('Image' => image.id, 'Cmd' => ['ls', '-1', '/'])
87
+ output = container.tap(&:start).attach(logs: true)
88
+ output[0].grep(/lol/).should_not be_empty
89
+ # TODO: stop resetting the connection, once no longer necessary after attach
90
+ Docker.reset_connection!
91
+ subject.instance_variable_set(:@connection, Docker.connection)
95
92
 
96
93
  # it 'exports'
97
- subject.export_image(images.last)
98
- expect(File.exist?('build/docker/test_docker-image.tgz')).to be_true
94
+ subject.export_image(image)
95
+ File.exist?('build/docker/test_docker-image.tgz').should be_true
99
96
  end
100
97
  end
101
98
 
@@ -151,7 +148,7 @@ describe Dockly::Docker do
151
148
  end
152
149
 
153
150
  describe "#export_image", :docker do
154
- let(:image) { Docker::Image.create('fromImage' => 'ubuntu:14.04') }
151
+ let(:image) { Docker::Image.create('fromImage' => 'base') }
155
152
 
156
153
  context "with a registry export" do
157
154
  let(:registry) { double(:registry) }
@@ -228,10 +225,7 @@ describe Dockly::Docker do
228
225
  end
229
226
 
230
227
  describe '#export_image_diff', :docker do
231
- let(:images) { [] }
232
228
  let(:output) { StringIO.new }
233
- let(:container) { images.last.run('true').tap { |c| c.wait(10) } }
234
-
235
229
  before do
236
230
  subject.instance_eval do
237
231
  import 'https://s3.amazonaws.com/swipely-pub/docker-export-ubuntu-test.tgz'
@@ -240,16 +234,11 @@ describe Dockly::Docker do
240
234
  end
241
235
  end
242
236
 
243
- after do
244
- container.remove
245
- images.last.remove
246
- end
247
-
248
237
  it "should export only the tar with the new file" do
249
238
  docker_tar = File.absolute_path(subject.ensure_tar(subject.fetch_import))
250
-
251
- images << subject.import_base(docker_tar)
252
- images << subject.build_image(images.last)
239
+ image = subject.import_base(docker_tar)
240
+ image = subject.build_image(image)
241
+ container = image.run('true').tap { |c| c.wait(10) }
253
242
  subject.export_image_diff(container, output)
254
243
 
255
244
  expect(output.string).to include('it_worked')
@@ -261,7 +250,7 @@ describe Dockly::Docker do
261
250
  let(:docker_file) { 'build/docker/dockly_test-image.tgz' }
262
251
  before { FileUtils.rm_rf(docker_file) }
263
252
 
264
- context 'with cleaning up' do
253
+ context 'without cleaning up' do
265
254
  before do
266
255
  subject.instance_eval do
267
256
  import 'https://s3.amazonaws.com/swipely-pub/docker-export-ubuntu-latest.tgz'
@@ -269,84 +258,78 @@ describe Dockly::Docker do
269
258
  build "run touch /it_worked"
270
259
  repository 'dockly_test'
271
260
  build_dir 'build/docker'
272
- cleanup_images true
261
+ cleanup_images false
273
262
  end
274
263
  end
275
264
 
276
265
  it 'builds a docker image' do
277
- expect { subject.generate! }.to_not change { ::Docker::Image.all(:all => true).length }
278
- expect(File.exist?(docker_file)).to be_true
279
- expect(Dockly::Util::Tar.is_gzip?(docker_file)).to be_true
280
- expect(File.size(docker_file)).to be > (1024 * 1024)
281
- paths = []
282
- Gem::Package::TarReader.new(Zlib::GzipReader.new(File.new(docker_file))).each do |entry|
283
- paths << entry.header.name
284
- end
285
- expect(paths.size).to be > 1000
286
- expect(paths).to include('sbin/init')
287
- expect(paths).to include('lib/dockly.rb')
288
- expect(paths).to include('it_worked')
266
+ expect {
267
+ subject.generate!
268
+ File.exist?(docker_file).should be_true
269
+ Dockly::Util::Tar.is_gzip?(docker_file).should be_true
270
+ File.size(docker_file).should be > (1024 * 1024)
271
+ paths = []
272
+ Gem::Package::TarReader.new(gz = Zlib::GzipReader.new(File.new(docker_file))).each do |entry|
273
+ paths << entry.header.name
274
+ end
275
+ paths.size.should be > 1000
276
+ paths.should include('sbin/init')
277
+ paths.should include('lib/dockly.rb')
278
+ paths.should include('it_worked')
279
+ }.to change { ::Docker::Image.all(:all => true).length }.by(3)
289
280
  end
290
281
  end
291
282
 
292
- context 'without cleaning up' do
283
+ context 'with cleaning up' do
293
284
  before do
294
285
  subject.instance_eval do
295
286
  import 'https://s3.amazonaws.com/swipely-pub/docker-export-ubuntu-latest.tgz'
296
287
  git_archive '.'
297
- build_env 'TEST_FILE' => 'it_worked'
298
- build "run touch $TEST_FILE"
288
+ build "run touch /it_worked"
299
289
  repository 'dockly_test'
300
290
  build_dir 'build/docker'
301
- cleanup_images false
302
- end
303
- end
304
-
305
- after do
306
- image = ::Docker::Image.all.find do |image|
307
- image.info['RepoTags'].include?('dockly_test:latest')
291
+ cleanup_images true
308
292
  end
309
- image.remove if image
310
293
  end
311
294
 
312
295
  it 'builds a docker image' do
313
- expect { subject.generate! }.to change { ::Docker::Image.all(:all => true).length }.by(4)
314
-
315
- expect(File.exist?(docker_file)).to be_true
316
- expect(Dockly::Util::Tar.is_gzip?(docker_file)).to be_true
317
- expect(File.size(docker_file)).to be > (1024 * 1024)
318
- paths = []
319
- Gem::Package::TarReader.new(Zlib::GzipReader.new(File.new(docker_file))).each do |entry|
320
- paths << entry.header.name
321
- end
322
- expect(paths.size).to be > 1000
323
- expect(paths).to include('sbin/init')
324
- expect(paths).to include('lib/dockly.rb')
325
- expect(paths).to include('it_worked')
296
+ expect {
297
+ subject.generate!
298
+ File.exist?(docker_file).should be_true
299
+ Dockly::Util::Tar.is_gzip?(docker_file).should be_true
300
+ File.size(docker_file).should be > (1024 * 1024)
301
+ paths = []
302
+ Gem::Package::TarReader.new(gz = Zlib::GzipReader.new(File.new(docker_file))).each do |entry|
303
+ paths << entry.header.name
304
+ end
305
+ paths.size.should be > 1000
306
+ paths.should include('sbin/init')
307
+ paths.should include('lib/dockly.rb')
308
+ paths.should include('it_worked')
309
+ }.to_not change { ::Docker::Image.all(:all => true).length }
326
310
  end
327
311
  end
328
312
 
329
313
  context 'when there is a registry' do
330
314
  subject {
331
315
  Dockly::Docker.new do
332
- registry_import 'tianon/true', :tag => 'latest'
316
+ registry_import 'nahiluhmot/base', :tag => 'latest'
333
317
  git_archive '.'
334
- build 'RUN ["/true", ""]'
318
+ build "run touch /it_worked"
335
319
  repository 'dockly_test'
336
320
  build_dir 'build/docker'
337
321
 
338
322
  registry do
339
- username ENV['DOCKER_USER']
340
- email ENV['DOCKER_EMAIL']
341
- password ENV['DOCKER_PASS']
323
+ username 'tlunter'
324
+ email 'tlunter@gmail.com'
325
+ password '******'
342
326
  end
343
327
  end
344
328
  }
345
329
 
346
330
  it 'pushes the image to the registry instead of exporting it' do
347
- image = subject.generate_build
348
- expect { ::Docker::Image.build("from #{ENV['DOCKER_USER']}/dockly_test") }.to_not raise_error
349
- image.remove unless image.nil?
331
+ subject.generate!
332
+ expect { ::Docker::Image.build('from nahiluhmot/dockly_test') }.to_not raise_error
350
333
  end
351
334
  end
352
335
  end
@@ -51,18 +51,11 @@ describe Dockly::Rpm do
51
51
  name 'rpm_test'
52
52
  import 'https://s3.amazonaws.com/swipely-pub/docker-export-ubuntu-latest.tgz'
53
53
  git_archive '.'
54
- build 'RUN touch /rpm_worked'
54
+ build 'touch /rpm_worked'
55
55
  build_dir 'build/docker'
56
56
  end
57
57
  end
58
58
 
59
- after do
60
- image = ::Docker::Image.all.find do |image|
61
- image.info['RepoTags'].include?('rpm_test:latest')
62
- end
63
- image.remove if image
64
- end
65
-
66
59
  it 'builds the docker image and adds it to the rpm' do
67
60
  subject.create_package!
68
61
  `rpm -qpl #{filename}`
@@ -76,25 +69,18 @@ describe Dockly::Rpm do
76
69
  name 'rpm_test'
77
70
  import 'https://s3.amazonaws.com/swipely-pub/docker-export-ubuntu-latest.tgz'
78
71
  git_archive '.'
79
- build 'RUN touch /rpm_worked'
72
+ build 'touch /rpm_worked'
80
73
  build_dir 'build/docker'
81
74
 
82
75
  registry :test_docker_registry do
83
76
  auth_config_file '/etc/docker/.dockercfg'
84
- username ENV['DOCKER_USER']
85
- email ENV['DOCKER_EMAIL']
86
- password ENV['DOCKER_PASS']
77
+ username 'tlunter'
78
+ email 'tlunter@gmail.com'
79
+ password '******'
87
80
  end
88
81
  end
89
82
  end
90
83
 
91
- after do
92
- image = ::Docker::Image.all.find do |image|
93
- image.info['RepoTags'].include?("#{ENV['DOCKER_USER']}/rpm_test:latest")
94
- end
95
- image.remove if image
96
- end
97
-
98
84
  it 'builds the docker image and adds it to the rpm' do
99
85
  subject.create_package!
100
86
  `rpm -qpl #{filename}`
@@ -153,15 +139,6 @@ describe Dockly::Rpm do
153
139
  subject.create_package!
154
140
  expect(`rpm -qpl #{filename}`).to include("dockly-startup.sh")
155
141
  end
156
-
157
- context 'when package_startup_script is false' do
158
- before { subject.package_startup_script(false) }
159
-
160
- it 'does not place a startup script in the package' do
161
- subject.create_package!
162
- expect(`rpm -qpl #{filename}`).to_not include("dockly-startup.sh")
163
- end
164
- end
165
142
  end
166
143
 
167
144
  describe '#exists?' do
@@ -0,0 +1,11 @@
1
+ require 'webmock'
2
+ require 'vcr'
3
+
4
+ WebMock.disable_net_connect!
5
+
6
+ VCR.configure do |c|
7
+ c.allow_http_connections_when_no_cassette = true
8
+ c.hook_into :webmock
9
+ c.cassette_library_dir = File.join(File.dirname(File.dirname(__FILE__)), 'vcr')
10
+ c.configure_rspec_metadata!
11
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dockly
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.13.0
4
+ version: 2.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-06-22 00:00:00.000000000 Z
12
+ date: 2015-02-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: clamp
@@ -139,22 +139,6 @@ dependencies:
139
139
  - - ! '>='
140
140
  - !ruby/object:Gem::Version
141
141
  version: '0'
142
- - !ruby/object:Gem::Dependency
143
- name: rugged
144
- requirement: !ruby/object:Gem::Requirement
145
- none: false
146
- requirements:
147
- - - ! '>='
148
- - !ruby/object:Gem::Version
149
- version: '0'
150
- type: :runtime
151
- prerelease: false
152
- version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
- requirements:
155
- - - ! '>='
156
- - !ruby/object:Gem::Version
157
- version: '0'
158
142
  - !ruby/object:Gem::Dependency
159
143
  name: cane
160
144
  requirement: !ruby/object:Gem::Requirement
@@ -286,7 +270,6 @@ files:
286
270
  - lib/dockly/docker.rb
287
271
  - lib/dockly/docker/registry.rb
288
272
  - lib/dockly/foreman.rb
289
- - lib/dockly/history.rb
290
273
  - lib/dockly/rake_task.rb
291
274
  - lib/dockly/rpm.rb
292
275
  - lib/dockly/tar_diff.rb
@@ -316,7 +299,6 @@ files:
316
299
  - spec/dockly/docker/registry_spec.rb
317
300
  - spec/dockly/docker_spec.rb
318
301
  - spec/dockly/foreman_spec.rb
319
- - spec/dockly/history_spec.rb
320
302
  - spec/dockly/rpm_spec.rb
321
303
  - spec/dockly/tar_diff_spec.rb
322
304
  - spec/dockly_spec.rb
@@ -329,6 +311,7 @@ files:
329
311
  - spec/fixtures/test-2.tar.gz
330
312
  - spec/fixtures/test-3.tar
331
313
  - spec/spec_helper.rb
314
+ - spec/support/vcr.rb
332
315
  homepage: https://github.com/swipely/dockly
333
316
  licenses:
334
317
  - MIT
@@ -366,7 +349,6 @@ test_files:
366
349
  - spec/dockly/docker/registry_spec.rb
367
350
  - spec/dockly/docker_spec.rb
368
351
  - spec/dockly/foreman_spec.rb
369
- - spec/dockly/history_spec.rb
370
352
  - spec/dockly/rpm_spec.rb
371
353
  - spec/dockly/tar_diff_spec.rb
372
354
  - spec/dockly_spec.rb
@@ -379,4 +361,4 @@ test_files:
379
361
  - spec/fixtures/test-2.tar.gz
380
362
  - spec/fixtures/test-3.tar
381
363
  - spec/spec_helper.rb
382
- has_rdoc:
364
+ - spec/support/vcr.rb
@@ -1,64 +0,0 @@
1
- # This module contains logic to find matching content hash for a given commit.
2
- module Dockly::History
3
- module_function
4
-
5
- ASCII_FILE_SEP = 28.chr
6
- ASCII_RECORD_SEP = 30.chr
7
-
8
- TAG_PREFIX = 'dockly-'
9
-
10
- def push_content_tag!
11
- fail 'An SSH agent must be running to push the tag' if ENV['SSH_AGENT_PID'].nil?
12
- refs = ["refs/tags/#{content_tag}"]
13
- repo.remotes.each do |remote|
14
- username = remote.url.split('@').first
15
- creds = Rugged::Credentials::SshKeyFromAgent.new(username: username)
16
- remote.push(refs, credentials: creds)
17
- end
18
- end
19
-
20
- def write_content_tag!
21
- repo.tags.create(content_tag, repo.head.target_id, true)
22
- end
23
-
24
- def duplicate_build?
25
- !duplicate_build_sha.nil?
26
- end
27
-
28
- def duplicate_build_sha
29
- return @duplicate_build_sha if @duplicate_build_sha
30
- sha = tags[content_tag]
31
- @duplicate_build_sha = sha unless sha == repo.head.target_id
32
- end
33
-
34
- def tags
35
- @tags ||= Hash.new do |hash, key|
36
- tag = repo.tags[key]
37
- hash[key] = tag.target_id if tag
38
- end
39
- end
40
-
41
- def content_tag
42
- @content_tag ||= TAG_PREFIX + content_hash_for(ls_files)
43
- end
44
-
45
- def ls_files
46
- repo.head.target.tree.walk(:preorder)
47
- .map { |root, elem| [root, elem[:name]].compact.join }
48
- .select(&File.method(:file?))
49
- end
50
-
51
- def content_hash_for(paths)
52
- paths.sort.each_with_object(Digest::SHA384.new) do |path, hash|
53
- next unless File.exist?(path)
54
- mode = File::Stat.new(path).mode
55
- data = File.read(path)
56
- str = [path, mode, data].join(ASCII_RECORD_SEP.chr) + ASCII_FILE_SEP.chr
57
- hash.update(str)
58
- end.hexdigest
59
- end
60
-
61
- def repo
62
- @repo ||= Rugged::Repository.discover('.')
63
- end
64
- end