Class: Fig::Lock::DockerClient
- Inherits:
-
Object
- Object
- Fig::Lock::DockerClient
- Defined in:
- lib/fig/lock/docker_client.rb
Instance Attribute Summary collapse
-
#cfg ⇒ Object
readonly
Returns the value of attribute cfg.
Instance Method Summary collapse
- #base(registry) ⇒ Object
-
#initialize(file = "#{ENV['HOME']}/.dockercfg") ⇒ DockerClient
constructor
A new instance of DockerClient.
- #tags(repo) ⇒ Object
Constructor Details
#initialize(file = "#{ENV['HOME']}/.dockercfg") ⇒ DockerClient
Returns a new instance of DockerClient.
11 12 13 |
# File 'lib/fig/lock/docker_client.rb', line 11 def initialize(file="#{ENV['HOME']}/.dockercfg") @cfg = JSON.parse(File.read(file)) end |
Instance Attribute Details
#cfg ⇒ Object (readonly)
Returns the value of attribute cfg.
9 10 11 |
# File 'lib/fig/lock/docker_client.rb', line 9 def cfg @cfg end |
Instance Method Details
#base(registry) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/fig/lock/docker_client.rb', line 28 def base(registry) config = cfg[registry] if config auth = Base64.decode64(config['auth']) RestClient::Resource.new("https://#{auth}@#{registry}") else RestClient::Resource.new("https://#{registry}") end end |
#tags(repo) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/fig/lock/docker_client.rb', line 15 def (repo) array = repo.split('/') registry = array[0] repo = array[1] name = array[2] if name.index(':') name = name.split(':')[0] end resource = base(registry)['v1']['repositories'][repo][name]['tags'] JSON.parse(resource.get.body) end |