class Armada::Docker::Config

Attributes

configs[R]

Public Class Methods

load(path) click to toggle source
# File lib/armada/docker/config.rb, line 21
def self.load(path)
  abs_path = File.expand_path path
  configs = []

  if File.readable? abs_path
    json_hash = JSON.parse(IO.read(abs_path))
    Armada.ui.info "Loading dockercfg from: #{abs_path}"
    json_hash.each do |url, obj|
      configs.push Credentials.parse(url, obj)
    end
  end

  Config.new configs
end
new(configs) click to toggle source
# File lib/armada/docker/config.rb, line 7
def initialize(configs)
  @configs = configs
end

Public Instance Methods

for_image(url) click to toggle source
# File lib/armada/docker/config.rb, line 11
def for_image(url)
  @configs.each do |config|        
    config_url = URI.parse(config.url).host || config.url
    if url.start_with? config_url
      return config
    end
  end
  nil
end