Project

General

Profile

Download (805 Bytes) Statistics
| Branch: | Tag: | Revision:

foreman_docker / app / models / docker_registry.rb @ 64f6a1f2

1
class DockerRegistry < ActiveRecord::Base
2
  include Authorizable
3
  include Taxonomix
4
  include Encryptable
5

    
6
  has_many :containers, :foreign_key => "registry_id", :dependent => :destroy
7
  encrypts :password
8

    
9
  scoped_search :on => :name, :complete_value => true
10
  scoped_search :on => :url
11

    
12
  def used_location_ids
13
    Location.joins(:taxable_taxonomies).where(
14
        'taxable_taxonomies.taxable_type' => 'DockerRegistry',
15
        'taxable_taxonomies.taxable_id' => id).pluck(:id)
16
  end
17

    
18
  def used_organization_ids
19
    Organization.joins(:taxable_taxonomies).where(
20
        'taxable_taxonomies.taxable_type' => 'DockerRegistry',
21
        'taxable_taxonomies.taxable_id' => id).pluck(:id)
22
  end
23

    
24
  def prefixed_url(image_name)
25
    uri = URI(url)
26
    "#{uri.hostname}:#{uri.port}/#{image_name}"
27
  end
28
end