Skip to content
Snippets Groups Projects
Commit c64d3630 authored by Andre Guedes's avatar Andre Guedes Committed by Grzegorz Bizon
Browse files

Makes ContainerImages Routable

Conflicts:
	db/schema.rb
parent c5912ecd
Branches
Tags
1 merge request!10109Multi-level container registry images
Pipeline #
class ContainerImage < ActiveRecord::Base class ContainerImage < ActiveRecord::Base
include Routable
belongs_to :project belongs_to :project
   
delegate :container_registry, :container_registry_allowed_paths, delegate :container_registry, :container_registry_allowed_paths,
Loading
@@ -17,10 +19,18 @@ class ContainerImage < ActiveRecord::Base
Loading
@@ -17,10 +19,18 @@ class ContainerImage < ActiveRecord::Base
client.update_token(token) client.update_token(token)
end end
   
def path def parent
[container_registry.path, name_with_namespace].compact.join('/') project
end
def parent_changed?
project_id_changed?
end end
   
# def path
# [container_registry.path, name_with_namespace].compact.join('/')
# end
def name_with_namespace def name_with_namespace
[container_registry_path_with_namespace, name].reject(&:blank?).join('/') [container_registry_path_with_namespace, name].reject(&:blank?).join('/')
end end
Loading
Loading
Loading
@@ -66,7 +66,7 @@ module Auth
Loading
@@ -66,7 +66,7 @@ module Auth
# per image authentication. # per image authentication.
# Removes only last occurence in light # Removes only last occurence in light
# of future nested groups # of future nested groups
namespace, _ = ContainerImage::split_namespace(name) namespace, a = ContainerImage::split_namespace(name)
requested_project = Project.find_by_full_path(namespace) requested_project = Project.find_by_full_path(namespace)
return unless requested_project return unless requested_project
   
Loading
Loading
Loading
@@ -31,5 +31,4 @@
Loading
@@ -31,5 +31,4 @@
- if can?(current_user, :update_container_image, @project) - if can?(current_user, :update_container_image, @project)
%th %th
   
- image.tags.each do |tag| = render partial: 'tag', collection: image.tags
= render 'tag', tag: tag
Loading
@@ -23,5 +23,4 @@
Loading
@@ -23,5 +23,4 @@
.nothing-here-block No container images in Container Registry for this project. .nothing-here-block No container images in Container Registry for this project.
   
- else - else
- @images.each do |image| = render partial: 'image', collection: @images
= render 'image', image: image
Loading
@@ -11,6 +11,7 @@ class CreateContainerImage < ActiveRecord::Migration
Loading
@@ -11,6 +11,7 @@ class CreateContainerImage < ActiveRecord::Migration
create_table :container_images do |t| create_table :container_images do |t|
t.integer :project_id t.integer :project_id
t.string :name t.string :name
t.string :path
end end
end end
end end
Loading
@@ -108,7 +108,6 @@ ActiveRecord::Schema.define(version: 20170315194013) do
Loading
@@ -108,7 +108,6 @@ ActiveRecord::Schema.define(version: 20170315194013) do
t.string "sidekiq_throttling_queues" t.string "sidekiq_throttling_queues"
t.decimal "sidekiq_throttling_factor" t.decimal "sidekiq_throttling_factor"
t.boolean "html_emails_enabled", default: true t.boolean "html_emails_enabled", default: true
t.string "container_registry_access_token"
t.string "plantuml_url" t.string "plantuml_url"
t.boolean "plantuml_enabled" t.boolean "plantuml_enabled"
t.integer "terminal_max_session_time", default: 0, null: false t.integer "terminal_max_session_time", default: 0, null: false
Loading
@@ -117,6 +116,7 @@ ActiveRecord::Schema.define(version: 20170315194013) do
Loading
@@ -117,6 +116,7 @@ ActiveRecord::Schema.define(version: 20170315194013) do
t.integer "unique_ips_limit_per_user" t.integer "unique_ips_limit_per_user"
t.integer "unique_ips_limit_time_window" t.integer "unique_ips_limit_time_window"
t.boolean "unique_ips_limit_enabled", default: false, null: false t.boolean "unique_ips_limit_enabled", default: false, null: false
t.string "container_registry_access_token"
end end
   
create_table "audit_events", force: :cascade do |t| create_table "audit_events", force: :cascade do |t|
Loading
@@ -327,6 +327,7 @@ ActiveRecord::Schema.define(version: 20170315194013) do
Loading
@@ -327,6 +327,7 @@ ActiveRecord::Schema.define(version: 20170315194013) do
create_table "container_images", force: :cascade do |t| create_table "container_images", force: :cascade do |t|
t.integer "project_id" t.integer "project_id"
t.string "name" t.string "name"
t.string "path"
end end
   
create_table "deploy_keys_projects", force: :cascade do |t| create_table "deploy_keys_projects", force: :cascade do |t|
Loading
Loading
Loading
@@ -44,7 +44,7 @@ module API
Loading
@@ -44,7 +44,7 @@ module API
project = Project::find_by_full_path(namespace) project = Project::find_by_full_path(namespace)
   
if project if project
container_image = project.container_images.find_or_create_by(name: container_image_name) container_image = project.container_images.find_or_create_by(name: container_image_name, path: container_image_name)
   
unless container_image.valid? unless container_image.valid?
render_api_error!({ error: "Failed to create container image!" }, 400) render_api_error!({ error: "Failed to create container image!" }, 400)
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment