Commit 5fbeb73a authored by Grzegorz Bizon's avatar Grzegorz Bizon

Add method that returns a registry repository location

parent 3d1cade1
...@@ -23,6 +23,10 @@ class ContainerRepository < ActiveRecord::Base ...@@ -23,6 +23,10 @@ class ContainerRepository < ActiveRecord::Base
@path ||= [project.full_path, name].select(&:present?).join('/') @path ||= [project.full_path, name].select(&:present?).join('/')
end end
def location
File.join(registry.path, path)
end
def tag(tag) def tag(tag)
ContainerRegistry::Tag.new(self, tag) ContainerRegistry::Tag.new(self, tag)
end end
......
...@@ -91,6 +91,21 @@ describe ContainerRepository do ...@@ -91,6 +91,21 @@ describe ContainerRepository do
end end
end end
describe '#location' do
context 'when registry is running on a custom port' do
before do
stub_container_registry_config(enabled: true,
api_url: 'http://registry.gitlab:5000',
host_port: 'registry.gitlab:5000')
end
it 'returns a full location of the repository' do
expect(container_repository.location)
.to eq 'registry.gitlab:5000/group/test/my_image'
end
end
end
describe '#root_repository?' do describe '#root_repository?' do
context 'when repository is a root repository' do context 'when repository is a root repository' do
let(:repository) { create(:container_repository, :root) } let(:repository) { create(:container_repository, :root) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment