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_update_image!, only: [:destroy]
before_action :tag, except: [:index]
layout 'project'
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
def destroy
if tag.delete
redirect_to namespace_project_images_path(project.namespace, project)
redirect_to namespace_project_container_registry_index_path(project.namespace, project)
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
private
def image_repository
@image_repository ||= project.image_repository
def container_registry
@container_registry ||= project.container_registry
end
def tag
@tag ||= image_repository[params[:id]]
@tag ||= container_registry[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
......
- header_title project_title(@project, "Container Registry", project_container_registry_path(@project))
- 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")
- 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
......
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