Commit 5196f8e9 authored by Kamil Trzcinski's avatar Kamil Trzcinski

WIP

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