Commit bf19a0ed authored by Thong Kuah's avatar Thong Kuah

Merge branch 'fix-CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX-for-non-lowercase-groups' into 'master'

ci: fix $CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX for non-lowercase groups

See merge request gitlab-org/gitlab!54559
parents e5aa7613 65f3844a
......@@ -99,6 +99,12 @@ module GroupsHelper
.count
end
def group_dependency_proxy_url(group)
# The namespace path can include uppercase letters, which
# Docker doesn't allow. The proxy expects it to be downcased.
"#{group_url(group).downcase}#{DependencyProxy::URL_SUFFIX}"
end
def group_icon_url(group, options = {})
if group.is_a?(String)
group = Group.find_by_full_path(group)
......
......@@ -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}"
- proxy_url = group_dependency_proxy_url(@group)
%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`
......
......@@ -18,11 +18,17 @@ RSpec.describe GroupsHelper do
it 'gives default avatar_icon when no avatar is present' do
group = create(:group)
group.save!
expect(group_icon_url(group.path)).to match_asset_path('group_avatar.png')
end
end
describe 'group_dependency_proxy_url' do
it 'converts uppercase letters to lowercase' do
group = create(:group, path: 'GroupWithUPPERcaseLetters')
expect(group_dependency_proxy_url(group)).to end_with("/groupwithuppercaseletters#{DependencyProxy::URL_SUFFIX}")
end
end
describe 'group_lfs_status' do
let(:group) { create(:group) }
let!(:project) { create(:project, namespace_id: group.id) }
......
......@@ -2482,7 +2482,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