Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ GEM
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
uri (>= 0.13.1)
addressable (2.9.2)
addressable (2.10.0)
public_suffix (>= 2.0.2, < 8.0)
ast (2.4.3)
backport (1.2.0)
Expand Down
2 changes: 1 addition & 1 deletion lib/cloud_controller/diego/docker/docker_uri_converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def convert(docker_uri)
# add tag or digest part as fragment to the uri, since ruby uri parser confuses with ':'
# when it presented in path. We convert user's uri to, for example;
# docker://docker.io/publish/ubuntu:latest -> docker://docker.io/publish/ubuntu#latest
Addressable::URI.new(scheme: 'docker', host: host, path: path, fragment: tag_digest).to_s
Addressable::URI.new(scheme: 'docker', authority: host, path: path, fragment: tag_digest).to_s
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,54 @@ module VCAP::CloudController
end
end

context('and the host is an IPv6 literal with a port') do
let(:image_url) { '[::1]:5000/image' }

it 'builds the correct rootFS path' do
expect(converter.convert(image_url)).to eq('docker://[::1]:5000/image')
end
end

context('and the port is zero') do
let(:image_url) { 'example.com:0/image' }

it 'drops the port' do
expect(converter.convert(image_url)).to eq('docker://example.com/image')
end
end

context('and the port has leading zeros') do
let(:image_url) { 'example.com:05000/image' }

it 'normalizes the port' do
expect(converter.convert(image_url)).to eq('docker://example.com:5000/image')
end
end

context('and the port is not numeric') do
let(:image_url) { 'example.com:abc/image' }

it 'raises an InvalidURIError' do
expect { converter.convert(image_url) }.to raise_error(Addressable::URI::InvalidURIError, /Invalid port number/)
end
end

context('and the port is empty') do
let(:image_url) { 'example.com:/image' }

it 'raises an InvalidURIError' do
expect { converter.convert(image_url) }.to raise_error(Addressable::URI::InvalidURIError, /Invalid port number/)
end
end

context('and the registry contains userinfo') do
let(:image_url) { 'user:pass@example.com/image' }

it 'keeps the userinfo in the rootFS path' do
expect(converter.convert(image_url)).to eq('docker://user:pass@example.com/image')
end
end

context('and user/image') do
let(:image_url) { '10.244.2.6:8080/user/image' }

Expand Down
Loading