class QB::Docker::Image::Name
Public Class Methods
all()
click to toggle source
# File lib/qb/docker/image/name.rb, line 172 def self.all QB::Docker::CLI.image_names load: true, only_named: true end
exists?(name)
click to toggle source
@see QB::Docker::CLI.image_named?
# File lib/qb/docker/image/name.rb, line 167 def self.exists? name QB::Docker::CLI.image_named? name end
from(source)
click to toggle source
Get an instance from a source.
@param [self | String | Hash] source @return [self]
# File lib/qb/docker/image/name.rb, line 154 def self.from source t.match source, self, source, t.str, method( :from_s ), t.hash_, method( :from_data ) end
from_s(string)
click to toggle source
Load from a {String}.
@param [String] string @return [self]
# File lib/qb/docker/image/name.rb, line 58 def self.from_s string strings = {} segments = string.split '/' if segments[-1].include? ':' rest, _, tag = segments[-1].rpartition ':' strings[:tag] = tag segments[-1] = rest else rest = string end case segments.length when 0 # Pass - construction will error when 1 # Just a name strings[:name] = segments[0] else if segments[0].include? ':' # segments = [s_0, s_1, ... s_n] # => repository = s_0 # segments = [s_1, s_2, ... s_n] # # like # # segments = ['docker.beiarea.com:8888', 'beiarea', 'wall'] # => registry_server = 'docker.beiarea.com' # port = '8888' # segments = ['beiarea', 'wall'] # registry_server, _, port = segments.shift.rpartition ':' strings[:registry_server] = registry_server strings[:port] = port end if segments.length > 1 # segments = [s_0, s_1, ... s_m] # => repository = s_0 # segments = [s_1, s_2, ... s_m] # # like # # segments = ['beiarea', 'wall'] # => repository = 'beiarea' # segments = ['wall'] # repository = segments.shift strings[:repository] = repository end # I think Docker image names *can* have more than just a repo and name # segment, though it's poorly supported from what I recall... though # we will handle it by just re-joining whatever's left into the name. # # segments = [s_0, s_1, ... s_p] # => name = "s_0/s_1/.../s_p" # # like # # segments = ['wall'] # => name = 'wall' # # or # # segments = ['www_rails', 'web'] # => name = 'www_rails/web' # strings[:name] = segments.join '/' end logger.debug "strings", strings # Now turn them into value using their prop types values = strings.transform_values_with_keys { |name, string| prop = metadata[name] if prop.type.respond_to? :from_s prop.type.from_s string else string end } logger.debug "values", values # And construct! new source: string, **values end
list(**attrs)
click to toggle source
@see QB::Docker::CLI.image_names
# File lib/qb/docker/image/name.rb, line 179 def self.list **attrs return all if attrs.empty? type = t.attrs attrs all.select { |name| type === name } end
Public Instance Methods
dirty?()
click to toggle source
@todo Document dirty? method.
@param [type] arg_name
@todo Add name param description.
@return [return_type]
@todo Document return value.
# File lib/qb/docker/image/name.rb, line 275 def dirty? !!tag.try( :dirty? ) end
exists?()
click to toggle source
Does the name exist in the local daemon?
@see QB::Docker::CLI.image_named?
@return [Boolean]
# File lib/qb/docker/image/name.rb, line 260 def exists? QB::Docker::CLI.image_named? self end
Also aliased as: exist?
formatted()
click to toggle source
# File lib/qb/docker/image/name.rb, line 291 def formatted [ host, repository, name, ].compact.join( '/' ).thru { |without_tag| if tag "#{ without_tag }:#{ tag }" else without_tag end } end
host()
click to toggle source
# File lib/qb/docker/image/name.rb, line 280 def host return unless registry_server if port "#{ registry_server }:#{ port }" else registry_server end end
inspect()
click to toggle source
# File lib/qb/docker/image/name.rb, line 311 def inspect "#<#{ self.class.safe_name } #{ to_s }>" end
pretty_print(q)
click to toggle source
# File lib/qb/docker/image/name.rb, line 316 def pretty_print q q.text inspect end
to_s()
click to toggle source
# File lib/qb/docker/image/name.rb, line 306 def to_s formatted end