dockly 4.0.0 → 4.1.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
- SHA256:
3
- metadata.gz: cdd9e8a044854b4149effa288483edb90a66ee8f58d35108696f0abc3a21ed95
4
- data.tar.gz: 8ee450caf29059b5c7a389683676953c02f3c497809eef2287648504d59c9023
2
+ SHA1:
3
+ metadata.gz: 0eb949e588205c02f1c15dbc3b609b7d14e3fd24
4
+ data.tar.gz: 52ab9c8916b071f0035400ced4c4fd73cf407885
5
5
  SHA512:
6
- metadata.gz: 2cf097573867f7c8ddafa597b0e0249780789fe098f6b4ffec3d48ae0b3dfc7cb6e48686214d846ab021c7cee5dec3bdd2c29f3423c1b82341d8173c2570fc05
7
- data.tar.gz: 5bb556418f6b975bc1cd2dfffcb0117ee61379b6426be681a80961f4831976319f91fd78e0e81c94bcd4a5ce3a7a1bb093f39d77379b2bb1708d2da7e7cfbaae
6
+ metadata.gz: e5ec4ce34a0bc5b270451dbd717988038a4ad3344e1a2f1d497a089cf287f3da1d8d3b940291575b8d69f75a9d00df685e36a1ec2cd9134e3d651d190f32dd75
7
+ data.tar.gz: 3400f1bf912778501d3b360d75a17d22e959ad68d1a5dee63bbfe9785d73bbb9a42fac4465486f8445469dbd6fd9f99b67c38be066edfd2f2dbd860d808d4ca9
@@ -26,6 +26,6 @@ module Dockly
26
26
  generate_snippet_for :registry_import, [:repo, :tag], { :tag => "latest" }
27
27
  generate_snippet_for :auth_ecr, [:server_address]
28
28
 
29
- generate_snippet_for :docker_tag_latest, [:repo, :tag]
29
+ generate_snippet_for :docker_tag_latest, [:repo, :tag, :new_name]
30
30
  end
31
31
  end
@@ -226,12 +226,13 @@ private
226
226
  if registry.is_a?(Dockly::Docker::ECR)
227
227
  scripts << bb.auth_ecr(registry.server_address)
228
228
  end
229
+
229
230
  scripts << bb.registry_import(docker.repo, docker.tag)
231
+ scripts << bb.docker_tag_latest(docker.repo, docker.tag, docker.name)
230
232
  else
231
233
  scripts += collect_non_registry_scripts(bb)
232
234
  end
233
235
  end
234
-
235
236
  scripts.join("\n")
236
237
  end
237
238
 
@@ -252,7 +253,8 @@ private
252
253
  scripts << bb.s3_docker_import(docker.s3_url, docker.name, docker.tag)
253
254
  end
254
255
  end
255
- scripts << bb.docker_tag_latest(docker.repo, docker.tag)
256
+
257
+ scripts << bb.docker_tag_latest(docker.repo, docker.tag, docker.repo)
256
258
  end
257
259
 
258
260
  def add_startup_script(package, startup_script = "dockly-startup.sh")
@@ -339,7 +339,11 @@ class Dockly::Docker
339
339
 
340
340
  raise "Could not find image after authentication" if image.nil?
341
341
 
342
- image.push(registry.to_h, :registry => registry.server_address)
342
+ image.push(registry.to_h, :registry => registry.server_address) do |resp|
343
+ if resp.include?('errorDetail')
344
+ raise "Error pushing to registry: #{resp}"
345
+ end
346
+ end
343
347
  end
344
348
 
345
349
  def fetch_import
@@ -1,6 +1,6 @@
1
1
  module Dockly
2
2
  MAJOR = 4
3
- MINOR = 0
3
+ MINOR = 1
4
4
  PATCH = 0
5
5
  RELEASE = nil
6
6
 
@@ -1,3 +1,3 @@
1
1
  <% if data[:tag] %>
2
- docker tag <%= data[:repo] %>:<%= data[:tag] %> <%= data[:repo] %>:latest
2
+ docker tag <%= data[:repo] %>:<%= data[:tag] %> <%= data[:new_name] %>:latest
3
3
  <% end %>
@@ -32,8 +32,8 @@ describe Dockly::BashBuilder do
32
32
 
33
33
  context "when there is a tag" do
34
34
  it "tags the repo:tag as repo:latest" do
35
- output = subject.docker_tag_latest("test_repo", "a_tag")
36
- expect(output).to include("docker tag test_repo:a_tag test_repo:latest")
35
+ output = subject.docker_tag_latest("registry/test_repo", "a_tag", "test_repo")
36
+ expect(output).to include("docker tag registry/test_repo:a_tag test_repo:latest")
37
37
  end
38
38
  end
39
39
  end
@@ -313,6 +313,107 @@ describe Dockly::Docker do
313
313
  end
314
314
  end
315
315
 
316
+ describe '#push_to_registry', :docker do
317
+ let(:image) { Docker::Image.create('fromImage' => 'ubuntu:14.04') }
318
+ let(:ecr) { double(:ecr) }
319
+
320
+ context 'when there is no registry' do
321
+ it 'raises' do
322
+ expect(subject.registry).to eq(nil)
323
+
324
+ expect { subject.push_to_registry(image) }.to raise_error(/No registry/)
325
+ end
326
+ end
327
+
328
+ context 'when there is a registry' do
329
+ before do
330
+ subject.instance_variable_set(:"@ecr", ecr)
331
+
332
+ allow(ecr)
333
+ .to receive(:server_address)
334
+ .and_return('server_address')
335
+
336
+ expect(subject.registry).to eq(ecr)
337
+ end
338
+
339
+ context "that can't be authenticated to" do
340
+ before do
341
+ allow(ecr)
342
+ .to receive(:authenticate!)
343
+ .and_raise
344
+ end
345
+
346
+ it 'raises' do
347
+ expect { subject.push_to_registry(image) }
348
+ .to raise_error(StandardError)
349
+ end
350
+ end
351
+
352
+ context 'that can be authenticated to' do
353
+ before do
354
+ allow(ecr).to receive(:authenticate!)
355
+
356
+ allow(Docker::Image)
357
+ .to receive(:all)
358
+ .with(all: true)
359
+ .and_return(available_images)
360
+ end
361
+
362
+ context "but the image isn't found" do
363
+ let(:available_images) { [] }
364
+
365
+ it 'raises' do
366
+ expect { subject.push_to_registry(image) }
367
+ .to raise_error(/Could not find image after authentication/)
368
+ end
369
+ end
370
+
371
+ context 'and the image is found' do
372
+ let(:available_images) { [image] }
373
+
374
+ before do
375
+ allow(ecr)
376
+ .to receive(:to_h)
377
+ .and_return({})
378
+ allow(image)
379
+ .to receive(:push)
380
+ .and_yield(push_message)
381
+ end
382
+
383
+ context 'but the push to the registry fails' do
384
+ let(:push_message) do
385
+ <<-EOF
386
+ {"errorDetail":{"message":"name unknown: The repository with name 'repository'
387
+ does not exist in the registry with id 'accoundid'"},"error":"name unknown:
388
+ The repository with name 'repository' does not exist in the registry with id 'accountid'"}
389
+ EOF
390
+ end
391
+
392
+ it 'raises' do
393
+ expect { subject.push_to_registry(image) }
394
+ .to raise_error(/Error pushing to registry/)
395
+ end
396
+ end
397
+
398
+ context 'and the push to the registry succeeds' do
399
+ let(:push_message) do
400
+ <<-EOF
401
+ {"status":"Pushed","progressDetail":{},"id":"id"}
402
+ {"status":"sha: digest: digest size: 2048"}
403
+ {"progressDetail":{},"aux":{"Tag":"sha","Digest":"digest","Size":2048}}
404
+ EOF
405
+ end
406
+
407
+ it 'passes' do
408
+ expect(subject.push_to_registry(image))
409
+ .not_to raise_error
410
+ end
411
+ end
412
+ end
413
+ end
414
+ end
415
+ end
416
+
316
417
  describe '#export_image_diff', :docker do
317
418
  let(:images) { [] }
318
419
  let(:output) { StringIO.new }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dockly
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Swipely, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-14 00:00:00.000000000 Z
11
+ date: 2021-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clamp
@@ -326,7 +326,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
326
326
  - !ruby/object:Gem::Version
327
327
  version: '0'
328
328
  requirements: []
329
- rubygems_version: 3.0.6
329
+ rubyforge_project:
330
+ rubygems_version: 2.5.1
330
331
  signing_key:
331
332
  specification_version: 4
332
333
  summary: Packaging made easy
@@ -356,3 +357,4 @@ test_files:
356
357
  - spec/fixtures/test-2.tar.gz
357
358
  - spec/fixtures/test-3.tar
358
359
  - spec/spec_helper.rb
360
+ has_rdoc: