diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 08:27:35 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 08:27:35 +0000 |
commit | 7e9c479f7de77702622631cff2628a9c8dcbc627 (patch) | |
tree | c8f718a08e110ad7e1894510980d2155a6549197 /lib/container_registry | |
parent | e852b0ae16db4052c1c567d9efa4facc81146e88 (diff) | |
download | gitlab-ce-7e9c479f7de77702622631cff2628a9c8dcbc627.tar.gz |
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'lib/container_registry')
-rw-r--r-- | lib/container_registry/client.rb | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/container_registry/client.rb b/lib/container_registry/client.rb index e6ca33d749b..35f299c17e4 100644 --- a/lib/container_registry/client.rb +++ b/lib/container_registry/client.rb @@ -15,6 +15,7 @@ module ContainerRegistry CONTAINER_IMAGE_V1_TYPE = 'application/vnd.docker.container.image.v1+json' REGISTRY_VERSION_HEADER = 'gitlab-container-registry-version' REGISTRY_FEATURES_HEADER = 'gitlab-container-registry-features' + REGISTRY_TAG_DELETE_FEATURE = 'tag_delete' ACCEPTED_TYPES = [DOCKER_DISTRIBUTION_MANIFEST_V2_TYPE, OCI_MANIFEST_V1_TYPE].freeze @@ -25,8 +26,6 @@ module ContainerRegistry registry_config = Gitlab.config.registry return false unless registry_config.enabled && registry_config.api_url.present? - return true if ::Gitlab.com? - token = Auth::ContainerRegistryAuthenticationService.access_token([], []) client = new(registry_config.api_url, token: token) client.supports_tag_delete? @@ -81,6 +80,9 @@ module ContainerRegistry # the DELETE method in the Allow header. Others reply with an 404 Not Found. def supports_tag_delete? strong_memoize(:supports_tag_delete) do + registry_features = Gitlab::CurrentSettings.container_registry_features || [] + next true if ::Gitlab.com? && registry_features.include?(REGISTRY_TAG_DELETE_FEATURE) + response = faraday.run_request(:options, '/v2/name/tags/reference/tag', '', {}) response.success? && response.headers['allow']&.include?('DELETE') end |