WIP
This commit is contained in:
parent
9e619d3813
commit
5196f8e993
|
@ -0,0 +1,31 @@
|
|||
class Projects::ContainerRegistryController < Projects::ApplicationController
|
||||
before_action :authorize_read_image!
|
||||
before_action :authorize_update_image!, only: [:destroy]
|
||||
before_action :tag, except: [:index]
|
||||
layout 'project'
|
||||
|
||||
def index
|
||||
@tags = container_registry.tags
|
||||
|
||||
other_repository = container_registry.registry["gitlab/gitlab-test3"]
|
||||
container_registry.copy_to(other_repository)
|
||||
end
|
||||
|
||||
def destroy
|
||||
if tag.delete
|
||||
redirect_to namespace_project_container_registry_index_path(project.namespace, project)
|
||||
else
|
||||
redirect_to namespace_project_container_registry_index_path(project.namespace, project), alert: 'Failed to remove tag'
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def container_registry
|
||||
@container_registry ||= project.container_registry
|
||||
end
|
||||
|
||||
def tag
|
||||
@tag ||= container_registry[params[:id]]
|
||||
end
|
||||
end
|
|
@ -1,28 +0,0 @@
|
|||
class Projects::ImagesController < Projects::ApplicationController
|
||||
before_action :authorize_read_image!
|
||||
before_action :authorize_update_image!, only: [:destroy]
|
||||
before_action :tag, except: [:index]
|
||||
layout 'project'
|
||||
|
||||
def index
|
||||
@tags = image_repository.tags
|
||||
end
|
||||
|
||||
def destroy
|
||||
if tag.delete
|
||||
redirect_to namespace_project_images_path(project.namespace, project)
|
||||
else
|
||||
redirect_to namespace_project_images_path(project.namespace, project), alert: 'Failed to remove tag'
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def image_repository
|
||||
@image_repository ||= project.image_repository
|
||||
end
|
||||
|
||||
def tag
|
||||
@tag ||= image_repository[params[:id]]
|
||||
end
|
||||
end
|
|
@ -33,8 +33,8 @@ module GitlabRoutingHelper
|
|||
namespace_project_builds_path(project.namespace, project, *args)
|
||||
end
|
||||
|
||||
def project_images_path(project, *args)
|
||||
namespace_project_images_path(project.namespace, project, *args)
|
||||
def project_container_registry_path(project, *args)
|
||||
namespace_project_container_registry_index_url(project.namespace, project, *args)
|
||||
end
|
||||
|
||||
def activity_project_path(project, *args)
|
||||
|
|
|
@ -370,10 +370,10 @@ class Project < ActiveRecord::Base
|
|||
@repository ||= Repository.new(path_with_namespace, self)
|
||||
end
|
||||
|
||||
def image_repository
|
||||
def container_registry
|
||||
@registry_token ||= Jwt::DockerAuthenticationService.full_access_token(path_with_namespace)
|
||||
@registry ||= ImageRegistry::Registry.new(Gitlab.config.registry.api_url, token: @registry_token)
|
||||
@image_repository ||= ImageRegistry::Repository.new(@registry, path_with_namespace)
|
||||
@container_registry ||= ImageRegistry::Repository.new(@registry, path_with_namespace)
|
||||
end
|
||||
|
||||
def registry_repository_url
|
||||
|
|
|
@ -47,11 +47,11 @@
|
|||
%span.count.builds_counter= number_with_delimiter(@project.builds.running_or_pending.count(:all))
|
||||
|
||||
- if project_nav_tab? :images
|
||||
= nav_link(controller: %w(images)) do
|
||||
= link_to project_images_path(@project), title: 'Images', class: 'shortcuts-images' do
|
||||
= nav_link(controller: %w(container_registry)) do
|
||||
= link_to project_container_registry_path(@project), title: 'Container Registry', class: 'shortcuts-images' do
|
||||
= icon('hdd-o fw')
|
||||
%span
|
||||
Container Images
|
||||
Container Registry
|
||||
|
||||
- if project_nav_tab? :graphs
|
||||
= nav_link(controller: %w(graphs)) do
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
- header_title project_title(@project, "Container Registry", project_container_registry_path(@project))
|
|
@ -1,4 +1,4 @@
|
|||
- page_title "Container Images"
|
||||
- page_title "Container Registry"
|
||||
= render "header_title"
|
||||
|
||||
.light.prepend-top-default
|
||||
|
@ -53,5 +53,5 @@
|
|||
= time_ago_in_words(tag.created_at)
|
||||
%td.content
|
||||
.controls.hidden-xs.pull-right
|
||||
= link_to namespace_project_image_path(@project.namespace, @project, tag.name), class: 'btn btn-remove has-tooltip', title: "Remove", data: { confirm: "Are you sure?" }, method: :delete do
|
||||
= link_to namespace_project_container_registry_path(@project.namespace, @project, tag.name), class: 'btn btn-remove has-tooltip', title: "Remove", data: { confirm: "Are you sure?" }, method: :delete do
|
||||
= icon("trash cred")
|
|
@ -1 +0,0 @@
|
|||
- header_title project_title(@project, "Container Images", project_images_path(@project))
|
|
@ -690,7 +690,7 @@ Rails.application.routes.draw do
|
|||
end
|
||||
end
|
||||
|
||||
resources :images, only: [:index, :destroy], constraints: { id: Gitlab::Regex.image_reference_regex }
|
||||
resources :container_registry, only: [:index, :destroy], constraints: { id: Gitlab::Regex.container_registry_reference_regex }
|
||||
|
||||
resources :milestones, constraints: { id: /\d+/ } do
|
||||
member do
|
||||
|
|
|
@ -97,7 +97,7 @@ module Gitlab
|
|||
}x.freeze
|
||||
end
|
||||
|
||||
def image_reference_regex
|
||||
def container_registry_reference_regex
|
||||
git_reference_regex
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue