From e601e683bcdee8eae00583aae713d69afc9eaa07 Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Wed, 1 Jun 2016 22:06:25 +0000 Subject: [PATCH] Merge branch 'downcase-registry-repository' into 'master' Use downcased path to container repository as this is expected path by Docker Docker Engine requires path to be lowercase. This makes all container registry paths to be show and used downcased instead of mixed case. Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/17959 See merge request !4420 --- CHANGELOG | 1 + app/models/project.rb | 10 +++++++--- spec/models/project_spec.rb | 9 +++++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 8865760217..2e57bdb078 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -13,6 +13,7 @@ v 8.8.3 - Add Application Setting to configure Container Registry token expire delay (default 5min). !4364 - Pass the "Remember me" value to the 2FA token form. !4369 - Fix incorrect links on pipeline page when merge request created from fork. !4376 + - Use downcased path to container repository as this is expected path by Docker. !4420 v 8.8.2 - Added remove due date button. !4209 diff --git a/app/models/project.rb b/app/models/project.rb index 37de1dfe4d..4e3d92507f 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -309,21 +309,25 @@ class Project < ActiveRecord::Base @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) + 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) + 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}" + "#{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 60e1ec43f2..3cabf3aef5 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -784,6 +784,15 @@ describe Project, models: true do 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) }