Sha256: d06d05a4501c2aeed6492ad716df0f9b968ae83acd927cd915c3b4f282a002b9
Contents?: true
Size: 1.48 KB
Versions: 1
Compression:
Stored size: 1.48 KB
Contents
class DockerRegistry < ActiveRecord::Base include Authorizable include Taxonomix include Encryptable default_scope do with_taxonomy_scope do order('docker_registries.name') end end has_many :containers, :foreign_key => "registry_id", :dependent => :destroy encrypts :password validates_lengths_from_database validates :name, :presence => true, :uniqueness => true validates :url, :presence => true, :uniqueness => true, :url_schema => ['http', 'https'] validate :attempt_login scoped_search :on => :name, :complete_value => true scoped_search :on => :url def used_location_ids Location.joins(:taxable_taxonomies).where( 'taxable_taxonomies.taxable_type' => 'DockerRegistry', 'taxable_taxonomies.taxable_id' => id).pluck("#{Taxonomy.table_name}.id") end def used_organization_ids Organization.joins(:taxable_taxonomies).where( 'taxable_taxonomies.taxable_type' => 'DockerRegistry', 'taxable_taxonomies.taxable_id' => id).pluck("#{Taxonomy.table_name}.id") end def prefixed_url(image_name) uri = URI(url) "#{uri.hostname}:#{uri.port}/#{image_name}" end def self.humanize_class_name(_name = nil) _("Docker/Registry") end def api @api ||= Service::RegistryApi.new(url: url, user: username, password: password) end private def attempt_login api.ok? rescue => e errors.add(:base, _('Unable to log in to this Docker Registry - %s') % e) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
foreman_docker-3.1.0 | app/models/docker_registry.rb |