Commit 3b5f46c4 authored by Eric Engestrom's avatar Eric Engestrom

ci: fix $CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX for non-lowercase groups

Docker does not allow uppercase characters in the image path, but GitLab
allows them in the group name, which is used in the dependency proxy's
image prefix.

The proxy already works with lowercased group names, the only thing
needed is to make sure we pass the correct prefix to the CI and to the
web page user.
parent a2ccb063
......@@ -2041,7 +2041,9 @@ class Project < ApplicationRecord
variables.append(key: 'CI_DEPENDENCY_PROXY_SERVER', value: Gitlab.host_with_port)
variables.append(
key: 'CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX',
value: "#{Gitlab.host_with_port}/#{namespace.root_ancestor.path}#{DependencyProxy::URL_SUFFIX}"
# The namespace path can include uppercase letters, which
# Docker doesn't allow. The proxy expects it to be downcased.
value: "#{Gitlab.host_with_port}/#{namespace.root_ancestor.path.downcase}#{DependencyProxy::URL_SUFFIX}"
)
end
end
......
- proxy_url = "#{group_url(@group)}#{DependencyProxy::URL_SUFFIX}"
-# The namespace path can include uppercase letters, which
-# Docker doesn't allow. The proxy expects it to be downcased.
- proxy_url = "#{group_url(@group).downcase}#{DependencyProxy::URL_SUFFIX}"
%h5.prepend-top-20= _('Dependency proxy URL')
......
---
title: Fix the value of `$CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX` when used in group with a name containing uppercase letters
merge_request: 54559
author: Eric Engestrom @1ace
type: fixed
......@@ -89,6 +89,7 @@ You can authenticate using:
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/280582) in GitLab 13.7.
> - Automatic runner authentication [added](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/27302) in GitLab 13.9.
> - The prefix for group names containing uppercase letters was [fixed](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/54559) in GitLab 13.10.
Runners log in to the Dependency Proxy automatically. To pull through
the Dependency Proxy, use the `CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX`
......
......@@ -2467,7 +2467,7 @@ RSpec.describe Ci::Build do
{ key: 'CI_PAGES_URL', value: project.pages_url, public: true, masked: false },
{ key: 'CI_DEPENDENCY_PROXY_SERVER', value: Gitlab.host_with_port, public: true, masked: false },
{ key: 'CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX',
value: "#{Gitlab.host_with_port}/#{project.namespace.root_ancestor.path}#{DependencyProxy::URL_SUFFIX}",
value: "#{Gitlab.host_with_port}/#{project.namespace.root_ancestor.path.downcase}#{DependencyProxy::URL_SUFFIX}",
public: true,
masked: false },
{ key: 'CI_API_V4_URL', value: 'http://localhost/api/v4', public: true, masked: false },
......
......@@ -4488,6 +4488,34 @@ RSpec.describe Project, factory_default: :keep do
end
end
describe '#dependency_proxy_variables' do
let_it_be(:namespace) { create(:namespace, path: 'NameWithUPPERcaseLetters') }
let_it_be(:project) { create(:project, :repository, namespace: namespace) }
subject { project.dependency_proxy_variables.to_runner_variables }
context 'when dependency_proxy is enabled' do
before do
stub_config(dependency_proxy: { enabled: true })
end
it 'contains the downcased name' do
expect(subject).to include({ key: 'CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX',
value: "#{Gitlab.host_with_port}/namewithuppercaseletters#{DependencyProxy::URL_SUFFIX}",
public: true,
masked: false })
end
end
context 'when dependency_proxy is disabled' do
before do
stub_config(dependency_proxy: { enabled: false })
end
it { expect(subject).to be_empty }
end
end
describe '#auto_devops_enabled?' do
before do
Feature.enable_percentage_of_actors(:force_autodevops_on_by_default, 0)
......
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