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.



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

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.



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

def creds
  @creds
end

#registry_urlObject (readonly)

Returns the value of attribute registry_url.



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

def registry_url
  @registry_url
end

#repoObject (readonly)

Returns the value of attribute repo.



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

def repo
  @repo
end

Instance Method Details

#catalogObject



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

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

#manifest_for(reference) ⇒ Object



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

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

#tagsObject



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

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