Commit 7005dd07 authored by Steve Abrams's avatar Steve Abrams

Add dependency proxy image prefix to group type

Add dependency_proxy_image_prefix attribute
to graphql group type.

Changelog: added
parent db82cd71
...@@ -158,6 +158,11 @@ module Types ...@@ -158,6 +158,11 @@ module Types
null: false, null: false,
description: 'Total size of the dependency proxy cached images.' 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:) def label(title:)
BatchLoader::GraphQL.for(title).batch(key: group) do |titles, loader, args| BatchLoader::GraphQL.for(title).batch(key: group) do |titles, loader, args|
LabelsFinder LabelsFinder
......
...@@ -25,15 +25,6 @@ module GroupsHelper ...@@ -25,15 +25,6 @@ module GroupsHelper
Ability.allowed?(current_user, :admin_group_member, group) Ability.allowed?(current_user, :admin_group_member, group)
end 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 = {}) def group_icon_url(group, options = {})
if group.is_a?(String) if group.is_a?(String)
group = Group.find_by_full_path(group) group = Group.find_by_full_path(group)
......
...@@ -261,6 +261,15 @@ class Group < Namespace ...@@ -261,6 +261,15 @@ class Group < Namespace
Gitlab::UrlBuilder.build(self, only_path: only_path) Gitlab::UrlBuilder.build(self, only_path: only_path)
end 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 def human_name
full_name full_name
end end
......
- proxy_url = group_dependency_proxy_image_prefix(@group) - proxy_url = @group.dependency_proxy_image_prefix
%h5.prepend-top-20= _('Dependency proxy image prefix') %h5.prepend-top-20= _('Dependency proxy image prefix')
......
...@@ -9758,6 +9758,7 @@ four standard [pagination arguments](#connection-pagination-arguments): ...@@ -9758,6 +9758,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="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="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="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="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="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. | | <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 ...@@ -21,7 +21,8 @@ RSpec.describe GitlabSchema.types['Group'] do
packages dependency_proxy_setting dependency_proxy_manifests packages dependency_proxy_setting dependency_proxy_manifests
dependency_proxy_blobs dependency_proxy_image_count dependency_proxy_blobs dependency_proxy_image_count
dependency_proxy_blob_count dependency_proxy_total_size 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) expect(described_class).to include_graphql_fields(*expected_fields)
......
...@@ -19,18 +19,6 @@ RSpec.describe GroupsHelper do ...@@ -19,18 +19,6 @@ RSpec.describe GroupsHelper do
end end
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 describe '#group_lfs_status' do
let_it_be_with_reload(:group) { create(:group) } let_it_be_with_reload(:group) { create(:group) }
let_it_be_with_reload(:project) { create(:project, namespace_id: group.id) } let_it_be_with_reload(:project) { create(:project, namespace_id: group.id) }
......
...@@ -2715,4 +2715,16 @@ RSpec.describe Group do ...@@ -2715,4 +2715,16 @@ RSpec.describe Group do
group.open_merge_requests_count group.open_merge_requests_count
end end
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 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