Skip to content

Commit

Permalink
Move @sha256 part to the image path for Docker LRP rootfs (cloudfound…
Browse files Browse the repository at this point in the history
…ry#3889)

Co-authored-by: Nicolas Bender <[email protected]>
  • Loading branch information
pbusko and nicolasbender authored Jul 18, 2024
1 parent 44d70c0 commit e5fb425
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/cloud_controller/diego/docker/docker_uri_converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ def convert(docker_uri)
raise UriUtils::InvalidDockerURI.new "Docker URI [#{docker_uri}] should not contain scheme" if docker_uri.include? '://'

host, path, tag = UriUtils.parse_docker_uri(docker_uri)

if !tag.nil? && tag.start_with?('@sha256:')
path = "#{path}@sha256"
tag.slice!('@sha256:')
end

Addressable::URI.new(scheme: 'docker', host: host, path: path, fragment: tag).to_s
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ module VCAP::CloudController
expect(converter.convert(image_url)).to eq('docker:///user/image#tag')
end
end

context('and a user/image@sha256:9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08') do
let(:image_url) { 'user/image@sha256:9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08' }

it 'builds the correct rootFS path' do
expect(converter.convert(image_url)).to eq('docker:///user/image@sha256#9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08')
end
end
end

context('and the docker image url has host:port') do
Expand Down

0 comments on commit e5fb425

Please sign in to comment.