diff options
author | Andre Guedes <andrebsguedes@gmail.com> | 2016-11-23 14:50:30 -0200 |
---|---|---|
committer | Andre Guedes <andrebsguedes@gmail.com> | 2017-02-22 11:29:06 -0300 |
commit | eed0b85ad084ad4d13cc26907102063d9372fe75 (patch) | |
tree | a928cbbe20327724da7ee040963d5a25f285da53 /app/models/project.rb | |
parent | dcd4beb8eb7bb7d0c2f720ef85c3da9f97a3dfe6 (diff) | |
download | gitlab-ce-eed0b85ad084ad4d13cc26907102063d9372fe75.tar.gz |
First iteration of container_image view
- Fixes project, container_image and tag deletion
- Removed container_images_repository
[ci skip]
Diffstat (limited to 'app/models/project.rb')
-rw-r--r-- | app/models/project.rb | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index 703e24eb79a..afaf2095a4c 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -157,7 +157,7 @@ class Project < ActiveRecord::Base has_one :import_data, dependent: :destroy, class_name: "ProjectImportData" has_one :project_feature, dependent: :destroy has_one :statistics, class_name: 'ProjectStatistics', dependent: :delete - has_one :container_images_repository, dependent: :destroy + has_many :container_images, dependent: :destroy has_many :commit_statuses, dependent: :destroy, foreign_key: :gl_project_id has_many :pipelines, dependent: :destroy, class_name: 'Ci::Pipeline', foreign_key: :gl_project_id @@ -405,15 +405,19 @@ class Project < ActiveRecord::Base path_with_namespace.downcase end - def container_registry_repository + def container_registry_allowed_paths + @container_registry_allowed_paths ||= [container_registry_path_with_namespace] + + container_images.map { |i| i.name_with_namespace } + end + + def container_registry return unless Gitlab.config.registry.enabled - @container_registry_repository ||= begin - token = Auth::ContainerRegistryAuthenticationService.full_access_token(container_registry_path_with_namespace) + @container_registry ||= begin + token = Auth::ContainerRegistryAuthenticationService.full_access_token(container_registry_allowed_paths) url = Gitlab.config.registry.api_url host_port = Gitlab.config.registry.host_port - registry = ContainerRegistry::Registry.new(url, token: token, path: host_port) - registry.repository(container_registry_path_with_namespace) + ContainerRegistry::Registry.new(url, token: token, path: host_port) end end @@ -424,9 +428,9 @@ class Project < ActiveRecord::Base end def has_container_registry_tags? - return unless container_registry_repository + return unless container_images - container_registry_repository.tags.any? + container_images.first.tags.any? end def commit(ref = 'HEAD') |