Class: Armada::Docker::Config
- Inherits:
-
Object
- Object
- Armada::Docker::Config
- Defined in:
- lib/armada/docker/config.rb
Instance Attribute Summary collapse
-
#configs ⇒ Object
readonly
Returns the value of attribute configs.
Class Method Summary collapse
Instance Method Summary collapse
- #for_image(url) ⇒ Object
-
#initialize(configs) ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize(configs) ⇒ Config
Returns a new instance of Config.
7 8 9 |
# File 'lib/armada/docker/config.rb', line 7 def initialize(configs) @configs = configs end |
Instance Attribute Details
#configs ⇒ Object (readonly)
Returns the value of attribute configs.
6 7 8 |
# File 'lib/armada/docker/config.rb', line 6 def configs @configs end |
Class Method Details
.load(path) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/armada/docker/config.rb', line 21 def self.load(path) abs_path = File. 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 |
Instance Method Details
#for_image(url) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# 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 |