diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-03-23 16:37:17 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-03-23 16:37:17 +0300 |
commit | f451173a191474be681d208eceb6a0148ba2c0d0 (patch) | |
tree | f72134816e48c14b0ca0e6a56817090cd031b2ef /app/models/container_repository.rb | |
parent | ea16ea5bfcb78f66c6bb37e470d387bf1ac26c9f (diff) |
Fix specs for container repository model class
Diffstat (limited to 'app/models/container_repository.rb')
-rw-r--r-- | app/models/container_repository.rb | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/app/models/container_repository.rb b/app/models/container_repository.rb index 2e78fc148b4..b3a8ec691de 100644 --- a/app/models/container_repository.rb +++ b/app/models/container_repository.rb @@ -1,16 +1,23 @@ class ContainerRepository < ActiveRecord::Base belongs_to :project - - delegate :container_registry, to: :project - delegate :client, to: :container_registry - + delegate :client, to: :registry validates :manifest, presence: true - + validates :name, presence: true before_destroy :delete_tags def registry - # TODO, container registry with image access level - token = Auth::ContainerRegistryAuthenticationService.image_token(self) + @registry ||= begin + token = Auth::ContainerRegistryAuthenticationService.full_access_token(path) + + url = Gitlab.config.registry.api_url + host_port = Gitlab.config.registry.host_port + + ContainerRegistry::Registry.new(url, token: token, path: host_port) + end + end + + def path + @path ||= "#{project.full_path}/#{name}" end def tag(tag) |