Sha256: 2eb7e0e0d6277b427af7c1a5098e61dda4b5c5d824c1f71fbb6097603e3d2075
Contents?: true
Size: 1.44 KB
Versions: 2
Compression:
Stored size: 1.44 KB
Contents
require 'uri' module Kuby module Docker class Metadata DEFAULT_DISTRO = :debian DEFAULT_REGISTRY_HOST = 'https://docker.io'.freeze LATEST_TAG = 'latest' attr_accessor :image_url attr_reader :definition, :distro def initialize(definition) @definition = definition @tags = [] end def image_url @image_url || default_image_url end def image_host @image_host ||= if image_url.include?('/') uri = parse_url(image_url) "#{uri.scheme}://#{uri.host}" else DEFAULT_REGISTRY_HOST end end def image_repo @image_repo ||= if image_url.include?('/') parse_url(image_url).path.sub(/\A\//, '') else image_url end end def tags @tags.empty? ? default_tags : @tags end def distro=(distro_name) @distro = distro_name end private def default_image_url # assuming dockerhub by not specifying full url @default_image_url ||= definition.app_name.downcase end def default_tags @default_tags ||= [ TimestampTag.new(Time.now).to_s, LATEST_TAG ] end def parse_url(url) uri = URI.parse(url) return uri if uri.scheme # force a scheme because URI.parse won't work properly without one URI.parse("https://#{url}") end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
kuby-core-0.2.0 | lib/kuby/docker/metadata.rb |
kuby-core-0.1.0 | lib/kuby/docker/metadata.rb |