Use downcased path to container repository as this is expected path by Docker

This commit is contained in:
Kamil Trzcinski 2016-06-01 20:43:33 +02:00
parent 5a377d20d5
commit 6e58e7ff7c
3 changed files with 18 additions and 3 deletions

View file

@ -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 - Fix bug when sorting issues by milestone due date and filtering by two or more labels
- Remove 'main language' feature - Remove 'main language' feature
- Pipelines can be canceled only when there are running builds - 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 - Projects pending deletion will render a 404 page
- Measure queue duration between gitlab-workhorse and Rails - Measure queue duration between gitlab-workhorse and Rails
- Make authentication service for Container Registry to be compatible with < Docker 1.11 - Make authentication service for Container Registry to be compatible with < Docker 1.11

View file

@ -313,17 +313,17 @@ class Project < ActiveRecord::Base
return unless Gitlab.config.registry.enabled return unless Gitlab.config.registry.enabled
@container_registry_repository ||= begin @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 url = Gitlab.config.registry.api_url
host_port = Gitlab.config.registry.host_port host_port = Gitlab.config.registry.host_port
registry = ContainerRegistry::Registry.new(url, token: token, path: 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
end end
def container_registry_repository_url def container_registry_repository_url
if Gitlab.config.registry.enabled if Gitlab.config.registry.enabled
"#{Gitlab.config.registry.host_port}/#{path_with_namespace}" "#{Gitlab.config.registry.host_port}/#{path_with_namespace.downcase}"
end end
end end

View file

@ -792,6 +792,13 @@ describe Project, models: true do
subject { project.container_registry_repository } subject { project.container_registry_repository }
it { is_expected.not_to be_nil } 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 end
describe '#container_registry_repository_url' do describe '#container_registry_repository_url' do
@ -810,6 +817,13 @@ describe Project, models: true do
end end
it { is_expected.not_to be_nil } 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 end
context 'for disabled registry' do context 'for disabled registry' do