Commit 2f1cb7ce authored by Kamil Trzcinski's avatar Kamil Trzcinski

Improve code design

parent 24145592
...@@ -8,10 +8,12 @@ class Projects::ContainerRegistryController < Projects::ApplicationController ...@@ -8,10 +8,12 @@ class Projects::ContainerRegistryController < Projects::ApplicationController
end end
def destroy def destroy
url = namespace_project_container_registry_index_path(project.namespace, project)
if tag.delete if tag.delete
redirect_to namespace_project_container_registry_index_path(project.namespace, project) redirect_to url
else else
redirect_to namespace_project_container_registry_index_path(project.namespace, project), alert: 'Failed to remove tag' redirect_to url, alert: 'Failed to remove tag'
end end
end end
......
...@@ -331,6 +331,8 @@ class Project < ActiveRecord::Base ...@@ -331,6 +331,8 @@ class Project < ActiveRecord::Base
end end
def container_registry_repository def container_registry_repository
return unless Gitlab.config.registry.enabled
@container_registry_repository ||= begin @container_registry_repository ||= begin
token = Auth::ContainerRegistryAuthenticationService.full_access_token(path_with_namespace) token = Auth::ContainerRegistryAuthenticationService.full_access_token(path_with_namespace)
url = Gitlab.config.registry.api_url url = Gitlab.config.registry.api_url
...@@ -347,9 +349,9 @@ class Project < ActiveRecord::Base ...@@ -347,9 +349,9 @@ class Project < ActiveRecord::Base
end end
def has_container_registry_tags? def has_container_registry_tags?
if Gitlab.config.registry.enabled return unless container_registry_repository
container_registry_repository.tags.any?
end container_registry_repository.tags.any?
end end
def commit(id = 'HEAD') def commit(id = 'HEAD')
......
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