From 6e58e7ff7ce151fb7a8329faef69cd3a42194216 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Wed, 1 Jun 2016 20:43:33 +0200 Subject: [PATCH 1/2] Use downcased path to container repository as this is expected path by Docker --- CHANGELOG | 1 + app/models/project.rb | 6 +++--- spec/models/project_spec.rb | 14 ++++++++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 848aaa8506e..d1cde40c1c7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -21,6 +21,7 @@ v 8.9.0 (unreleased) - Fix bug when sorting issues by milestone due date and filtering by two or more labels - Remove 'main language' feature - Pipelines can be canceled only when there are running builds + - Use downcased path to container repository as this is expected path by Docker - Projects pending deletion will render a 404 page - Measure queue duration between gitlab-workhorse and Rails - Make authentication service for Container Registry to be compatible with < Docker 1.11 diff --git a/app/models/project.rb b/app/models/project.rb index c1d9bae44c9..13376da9948 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -313,17 +313,17 @@ def container_registry_repository return unless Gitlab.config.registry.enabled @container_registry_repository ||= begin - token = Auth::ContainerRegistryAuthenticationService.full_access_token(path_with_namespace) + token = Auth::ContainerRegistryAuthenticationService.full_access_token(path_with_namespace.downcase) url = Gitlab.config.registry.api_url host_port = Gitlab.config.registry.host_port registry = ContainerRegistry::Registry.new(url, token: token, path: host_port) - registry.repository(path_with_namespace) + registry.repository(path_with_namespace.downcase) end end def container_registry_repository_url if Gitlab.config.registry.enabled - "#{Gitlab.config.registry.host_port}/#{path_with_namespace}" + "#{Gitlab.config.registry.host_port}/#{path_with_namespace.downcase}" end end diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 6c1b0393682..65f06b51794 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -792,6 +792,13 @@ subject { project.container_registry_repository } it { is_expected.not_to be_nil } + + context 'for uppercase project path' do + let(:project) { create(:empty_project, path: 'PROJECT') } + + it { expect(subject.path).not_to end_with(project.path) } + it { expect(subject.path).to end_with(project.path.downcase) } + end end describe '#container_registry_repository_url' do @@ -810,6 +817,13 @@ end it { is_expected.not_to be_nil } + + context 'for uppercase project path' do + let(:project) { create(:empty_project, path: 'PROJECT') } + + it { is_expected.not_to end_with(project.path) } + it { is_expected.to end_with(project.path.downcase) } + end end context 'for disabled registry' do -- GitLab From 77cb8ec4d14e3a8b03164423176b3b95977ee809 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Wed, 1 Jun 2016 22:57:50 +0200 Subject: [PATCH 2/2] Introduce container_registry_path_with_namespace --- app/models/project.rb | 10 +++++++--- spec/models/project_spec.rb | 23 +++++++++-------------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/app/models/project.rb b/app/models/project.rb index 13376da9948..525a82c7534 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -309,21 +309,25 @@ def repository @repository ||= Repository.new(path_with_namespace, self) end + def container_registry_path_with_namespace + path_with_namespace.downcase + end + def container_registry_repository return unless Gitlab.config.registry.enabled @container_registry_repository ||= begin - token = Auth::ContainerRegistryAuthenticationService.full_access_token(path_with_namespace.downcase) + token = Auth::ContainerRegistryAuthenticationService.full_access_token(container_registry_path_with_namespace) url = Gitlab.config.registry.api_url host_port = Gitlab.config.registry.host_port registry = ContainerRegistry::Registry.new(url, token: token, path: host_port) - registry.repository(path_with_namespace.downcase) + registry.repository(container_registry_path_with_namespace) end end def container_registry_repository_url if Gitlab.config.registry.enabled - "#{Gitlab.config.registry.host_port}/#{path_with_namespace.downcase}" + "#{Gitlab.config.registry.host_port}/#{container_registry_path_with_namespace}" end end diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 65f06b51794..338a4c3d3f0 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -784,6 +784,15 @@ end end + describe '#container_registry_path_with_namespace' do + let(:project) { create(:empty_project, path: 'PROJECT') } + + subject { project.container_registry_path_with_namespace } + + it { is_expected.not_to eq(project.path_with_namespace) } + it { is_expected.to eq(project.path_with_namespace.downcase) } + end + describe '#container_registry_repository' do let(:project) { create(:empty_project) } @@ -792,13 +801,6 @@ subject { project.container_registry_repository } it { is_expected.not_to be_nil } - - context 'for uppercase project path' do - let(:project) { create(:empty_project, path: 'PROJECT') } - - it { expect(subject.path).not_to end_with(project.path) } - it { expect(subject.path).to end_with(project.path.downcase) } - end end describe '#container_registry_repository_url' do @@ -817,13 +819,6 @@ end it { is_expected.not_to be_nil } - - context 'for uppercase project path' do - let(:project) { create(:empty_project, path: 'PROJECT') } - - it { is_expected.not_to end_with(project.path) } - it { is_expected.to end_with(project.path.downcase) } - end end context 'for disabled registry' do -- GitLab