Commit 18033220 authored by Doug Stull's avatar Doug Stull

Merge branch '322839-dp-graphql-image-prefix' into 'master'

Add dependency_proxy_image_prefix attribute
to graphql group type.

See merge request gitlab-org/gitlab!69114

Changelog: added
parents 6d2ad959 7005dd07
......@@ -158,6 +158,11 @@ module Types
null: false,
description: 'Total size of the dependency proxy cached images.'
field :dependency_proxy_image_prefix,
GraphQL::Types::String,
null: false,
description: 'Prefix for pulling images when using the dependency proxy.'
def label(title:)
BatchLoader::GraphQL.for(title).batch(key: group) do |titles, loader, args|
LabelsFinder
......
......@@ -25,15 +25,6 @@ module GroupsHelper
Ability.allowed?(current_user, :admin_group_member, group)
end
def group_dependency_proxy_image_prefix(group)
# The namespace path can include uppercase letters, which
# Docker doesn't allow. The proxy expects it to be downcased.
url = "#{group_url(group).downcase}#{DependencyProxy::URL_SUFFIX}"
# Docker images do not include the protocol
url.partition('//').last
end
def group_icon_url(group, options = {})
if group.is_a?(String)
group = Group.find_by_full_path(group)
......
......@@ -261,6 +261,15 @@ class Group < Namespace
Gitlab::UrlBuilder.build(self, only_path: only_path)
end
def dependency_proxy_image_prefix
# The namespace path can include uppercase letters, which
# Docker doesn't allow. The proxy expects it to be downcased.
url = "#{web_url.downcase}#{DependencyProxy::URL_SUFFIX}"
# Docker images do not include the protocol
url.partition('//').last
end
def human_name
full_name
end
......
- proxy_url = group_dependency_proxy_image_prefix(@group)
- proxy_url = @group.dependency_proxy_image_prefix
%h5.prepend-top-20= _('Dependency proxy image prefix')
......
......@@ -9788,6 +9788,7 @@ four standard [pagination arguments](#connection-pagination-arguments):
| <a id="groupdependencyproxyblobcount"></a>`dependencyProxyBlobCount` | [`Int!`](#int) | Number of dependency proxy blobs cached in the group. |
| <a id="groupdependencyproxyblobs"></a>`dependencyProxyBlobs` | [`DependencyProxyBlobConnection`](#dependencyproxyblobconnection) | Dependency Proxy blobs. (see [Connections](#connections)) |
| <a id="groupdependencyproxyimagecount"></a>`dependencyProxyImageCount` | [`Int!`](#int) | Number of dependency proxy images cached in the group. |
| <a id="groupdependencyproxyimageprefix"></a>`dependencyProxyImagePrefix` | [`String!`](#string) | Prefix for pulling images when using the dependency proxy. |
| <a id="groupdependencyproxymanifests"></a>`dependencyProxyManifests` | [`DependencyProxyManifestConnection`](#dependencyproxymanifestconnection) | Dependency Proxy manifests. (see [Connections](#connections)) |
| <a id="groupdependencyproxysetting"></a>`dependencyProxySetting` | [`DependencyProxySetting`](#dependencyproxysetting) | Dependency Proxy settings for the group. |
| <a id="groupdependencyproxytotalsize"></a>`dependencyProxyTotalSize` | [`String!`](#string) | Total size of the dependency proxy cached images. |
......
......@@ -21,7 +21,8 @@ RSpec.describe GitlabSchema.types['Group'] do
packages dependency_proxy_setting dependency_proxy_manifests
dependency_proxy_blobs dependency_proxy_image_count
dependency_proxy_blob_count dependency_proxy_total_size
shared_runners_setting timelogs organizations
dependency_proxy_image_prefix shared_runners_setting
timelogs organizations
]
expect(described_class).to include_graphql_fields(*expected_fields)
......
......@@ -19,18 +19,6 @@ RSpec.describe GroupsHelper do
end
end
describe '#group_dependency_proxy_image_prefix' do
let_it_be(:group) { build_stubbed(:group, path: 'GroupWithUPPERcaseLetters') }
it 'converts uppercase letters to lowercase' do
expect(group_dependency_proxy_image_prefix(group)).to end_with("/groupwithuppercaseletters#{DependencyProxy::URL_SUFFIX}")
end
it 'removes the protocol' do
expect(group_dependency_proxy_image_prefix(group)).not_to include('http')
end
end
describe '#group_lfs_status' do
let_it_be_with_reload(:group) { create(:group) }
let_it_be_with_reload(:project) { create(:project, namespace_id: group.id) }
......
......@@ -2715,4 +2715,16 @@ RSpec.describe Group do
group.open_merge_requests_count
end
end
describe '#dependency_proxy_image_prefix' do
let_it_be(:group) { build_stubbed(:group, path: 'GroupWithUPPERcaseLetters') }
it 'converts uppercase letters to lowercase' do
expect(group.dependency_proxy_image_prefix).to end_with("/groupwithuppercaseletters#{DependencyProxy::URL_SUFFIX}")
end
it 'removes the protocol' do
expect(group.dependency_proxy_image_prefix).not_to include('http')
end
end
end
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