Rename container image model to container repository
This commit is contained in:
parent
bd8c8df6ed
commit
01d159b409
|
@ -1,4 +1,4 @@
|
|||
class ContainerImage < ActiveRecord::Base
|
||||
class ContainerRepository < ActiveRecord::Base
|
||||
belongs_to :project
|
||||
|
||||
delegate :container_registry, to: :project
|
||||
|
@ -18,7 +18,7 @@ class ContainerImage < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def manifest
|
||||
@manifest ||= client.repository_tags(name_with_namespace)
|
||||
@manifest ||= client.repository_tags(self.path)
|
||||
end
|
||||
|
||||
def tags
|
||||
|
@ -39,24 +39,24 @@ class ContainerImage < ActiveRecord::Base
|
|||
|
||||
digests = tags.map {|tag| tag.digest }.to_set
|
||||
digests.all? do |digest|
|
||||
client.delete_repository_tag(name_with_namespace, digest)
|
||||
client.delete_repository_tag(self.path, digest)
|
||||
end
|
||||
end
|
||||
|
||||
def self.project_from_path(image_path)
|
||||
return unless image_path.include?('/')
|
||||
def self.project_from_path(repository_path)
|
||||
return unless repository_path.include?('/')
|
||||
|
||||
##
|
||||
# Projects are always located inside a namespace, so we can remove
|
||||
# the last node, and see if project with that path exists.
|
||||
#
|
||||
truncated_path = image_path.slice(0...image_path.rindex('/'))
|
||||
truncated_path = repository_path.slice(0...repository_path.rindex('/'))
|
||||
|
||||
##
|
||||
# We still make it possible to search projects by a full image path
|
||||
# in order to maintain backwards compatibility.
|
||||
#
|
||||
Project.find_by_full_path(truncated_path) ||
|
||||
Project.find_by_full_path(image_path)
|
||||
Project.find_by_full_path(repository_path)
|
||||
end
|
||||
end
|
|
@ -62,7 +62,7 @@ module Auth
|
|||
end
|
||||
|
||||
def process_repository_access(type, name, actions)
|
||||
requested_project = ContainerImage.project_from_path(name)
|
||||
requested_project = ContainerRepository.project_from_path(name)
|
||||
|
||||
return unless requested_project
|
||||
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
class CreateContainerImage < ActiveRecord::Migration
|
||||
class CreateContainerRepository < ActiveRecord::Migration
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
|
||||
def change
|
||||
create_table :container_images do |t|
|
||||
create_table :container_repositories do |t|
|
||||
t.integer :project_id
|
||||
t.string :name
|
||||
t.string :path
|
||||
end
|
||||
end
|
10
db/schema.rb
10
db/schema.rb
|
@ -61,7 +61,6 @@ ActiveRecord::Schema.define(version: 20170322013926) do
|
|||
t.boolean "shared_runners_enabled", default: true, null: false
|
||||
t.integer "max_artifacts_size", default: 100, null: false
|
||||
t.string "runners_registration_token"
|
||||
t.integer "max_pages_size", default: 100, null: false
|
||||
t.boolean "require_two_factor_authentication", default: false
|
||||
t.integer "two_factor_grace_period", default: 48
|
||||
t.boolean "metrics_enabled", default: false
|
||||
|
@ -111,6 +110,7 @@ ActiveRecord::Schema.define(version: 20170322013926) do
|
|||
t.string "plantuml_url"
|
||||
t.boolean "plantuml_enabled"
|
||||
t.integer "terminal_max_session_time", default: 0, null: false
|
||||
t.integer "max_pages_size", default: 100, null: false
|
||||
t.string "default_artifacts_expire_in", default: "0", null: false
|
||||
t.integer "unique_ips_limit_per_user"
|
||||
t.integer "unique_ips_limit_time_window"
|
||||
|
@ -322,9 +322,8 @@ ActiveRecord::Schema.define(version: 20170322013926) do
|
|||
|
||||
add_index "ci_variables", ["project_id"], name: "index_ci_variables_on_project_id", using: :btree
|
||||
|
||||
create_table "container_images", force: :cascade do |t|
|
||||
create_table "container_repositories", force: :cascade do |t|
|
||||
t.integer "project_id"
|
||||
t.string "name"
|
||||
t.string "path"
|
||||
end
|
||||
|
||||
|
@ -694,8 +693,8 @@ ActiveRecord::Schema.define(version: 20170322013926) do
|
|||
t.integer "visibility_level", default: 20, null: false
|
||||
t.boolean "request_access_enabled", default: false, null: false
|
||||
t.datetime "deleted_at"
|
||||
t.text "description_html"
|
||||
t.boolean "lfs_enabled"
|
||||
t.text "description_html"
|
||||
t.integer "parent_id"
|
||||
end
|
||||
|
||||
|
@ -991,7 +990,6 @@ ActiveRecord::Schema.define(version: 20170322013926) do
|
|||
end
|
||||
|
||||
add_index "routes", ["path"], name: "index_routes_on_path", unique: true, using: :btree
|
||||
add_index "routes", ["path"], name: "index_routes_on_path_text_pattern_ops", using: :btree, opclasses: {"path"=>"varchar_pattern_ops"}
|
||||
add_index "routes", ["source_type", "source_id"], name: "index_routes_on_source_type_and_source_id", unique: true, using: :btree
|
||||
|
||||
create_table "sent_notifications", force: :cascade do |t|
|
||||
|
@ -1238,8 +1236,8 @@ ActiveRecord::Schema.define(version: 20170322013926) do
|
|||
t.datetime "otp_grace_period_started_at"
|
||||
t.boolean "ldap_email", default: false, null: false
|
||||
t.boolean "external", default: false
|
||||
t.string "incoming_email_token"
|
||||
t.string "organization"
|
||||
t.string "incoming_email_token"
|
||||
t.boolean "authorized_projects_populated"
|
||||
t.boolean "ghost"
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue