summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-04-10 12:57:19 +0200
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-04-10 12:57:19 +0200
commit5fbeb73a76ca21db02146a7686dc13a7c961cc87 (patch)
tree6fdea49e075c301c18010769bd35868c30a37517
parent3d1cade13f61115b63bf6dbda5a1f194ba54b24b (diff)
downloadgitlab-ce-5fbeb73a76ca21db02146a7686dc13a7c961cc87.tar.gz
Add method that returns a registry repository location
-rw-r--r--app/models/container_repository.rb4
-rw-r--r--spec/models/container_repository_spec.rb15
2 files changed, 19 insertions, 0 deletions
diff --git a/app/models/container_repository.rb b/app/models/container_repository.rb
index 9682df3a586..82f4182d59a 100644
--- a/app/models/container_repository.rb
+++ b/app/models/container_repository.rb
@@ -23,6 +23,10 @@ class ContainerRepository < ActiveRecord::Base
@path ||= [project.full_path, name].select(&:present?).join('/')
end
+ def location
+ File.join(registry.path, path)
+ end
+
def tag(tag)
ContainerRegistry::Tag.new(self, tag)
end
diff --git a/spec/models/container_repository_spec.rb b/spec/models/container_repository_spec.rb
index f7ee0b57072..cfb1645f751 100644
--- a/spec/models/container_repository_spec.rb
+++ b/spec/models/container_repository_spec.rb
@@ -91,6 +91,21 @@ describe ContainerRepository do
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
context 'when repository is a root repository' do
let(:repository) { create(:container_repository, :root) }