Commit c64d3630 authored by Andre Guedes's avatar Andre Guedes Committed by Grzegorz Bizon

Makes ContainerImages Routable

Conflicts:
	db/schema.rb
parent c5912ecd
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,
...@@ -17,10 +19,18 @@ class ContainerImage < ActiveRecord::Base ...@@ -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
......
...@@ -66,7 +66,7 @@ module Auth ...@@ -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
......
...@@ -31,5 +31,4 @@ ...@@ -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
...@@ -23,5 +23,4 @@ ...@@ -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
...@@ -11,6 +11,7 @@ class CreateContainerImage < ActiveRecord::Migration ...@@ -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
...@@ -108,7 +108,6 @@ ActiveRecord::Schema.define(version: 20170315194013) do ...@@ -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
...@@ -117,6 +116,7 @@ ActiveRecord::Schema.define(version: 20170315194013) do ...@@ -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|
...@@ -327,6 +327,7 @@ ActiveRecord::Schema.define(version: 20170315194013) do ...@@ -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|
......
...@@ -44,7 +44,7 @@ module API ...@@ -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)
......
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