Sha256: 092e4ef106fab4931a6736b6ab378f22488b0ae4f6af81b2f38150411cae2d7f
Contents?: true
Size: 1.71 KB
Versions: 5
Compression:
Stored size: 1.71 KB
Contents
class DockerRegistry < ApplicationRecord 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, verify_ssl: verify_ssl) end private def attempt_login api.ok? rescue Excon::Error::Certificate message = 'Unable to verify certificate.\ (Disable "Verify ssl" if you still want to use this Docker Registry)' errors.add(:base, _(message)) rescue => error errors.add(:base, _('Unable to log in to this Docker Registry - %s') % error) end end
Version data entries
5 entries across 5 versions & 1 rubygems