Commit 3b53016f authored by Stan Hu's avatar Stan Hu

Merge branch 'downcase-registry-repository' into 'master'

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

## What does this MR do?

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
parents 07fb3815 77cb8ec4
...@@ -21,6 +21,7 @@ v 8.9.0 (unreleased) ...@@ -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
......
...@@ -309,21 +309,25 @@ class Project < ActiveRecord::Base ...@@ -309,21 +309,25 @@ class Project < ActiveRecord::Base
@repository ||= Repository.new(path_with_namespace, self) @repository ||= Repository.new(path_with_namespace, self)
end end
def container_registry_path_with_namespace
path_with_namespace.downcase
end
def container_registry_repository def container_registry_repository
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(container_registry_path_with_namespace)
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(container_registry_path_with_namespace)
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}/#{container_registry_path_with_namespace}"
end end
end end
......
...@@ -784,6 +784,15 @@ describe Project, models: true do ...@@ -784,6 +784,15 @@ describe Project, models: true do
end end
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 describe '#container_registry_repository' do
let(:project) { create(:empty_project) } let(:project) { create(:empty_project) }
......
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