Class: Docker::Remote::Client

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/docker/remote/client.rb

Constant Summary collapse

PORTMAP =
{ 'ghcr.io' => 443 }.freeze
DEFAULT_PORT =
443
STANDARD_PORTS =
[DEFAULT_PORT, 80].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils

#potentially_raise_error!

Constructor Details

#initialize(registry_url, repo, username = nil, password = nil) ⇒ Client

Returns a new instance of Client.



21
22
23
24
25
# File 'lib/docker/remote/client.rb', line 21

def initialize(registry_url, repo, username = nil, password = nil)
  @registry_url = registry_url
  @repo = repo
  @creds = Credentials.new(username, password)
end

Instance Attribute Details

#credsObject (readonly)

Returns the value of attribute creds.



15
16
17
# File 'lib/docker/remote/client.rb', line 15

def creds
  @creds
end

#registry_urlObject (readonly)

Returns the value of attribute registry_url.



15
16
17
# File 'lib/docker/remote/client.rb', line 15

def registry_url
  @registry_url
end

#repoObject (readonly)

Returns the value of attribute repo.



15
16
17
# File 'lib/docker/remote/client.rb', line 15

def repo
  @repo
end

Instance Method Details

#catalogObject



39
40
41
42
43
# File 'lib/docker/remote/client.rb', line 39

def catalog
  response = get("/v2/_catalog")
  potentially_raise_error!(response)
  JSON.parse(response.body)
end

#manifest_for(reference) ⇒ Object



33
34
35
36
37
# File 'lib/docker/remote/client.rb', line 33

def manifest_for(reference)
  response = get("/v2/#{repo}/manifests/#{reference}")
  potentially_raise_error!(response)
  JSON.parse(response.body)
end

#tagsObject



27
28
29
30
31
# File 'lib/docker/remote/client.rb', line 27

def tags
  response = get("/v2/#{repo}/tags/list")
  potentially_raise_error!(response)
  JSON.parse(response.body)['tags']
end