Class: Dapp::DockerRegistry::Base
- Inherits:
-
Object
- Object
- Dapp::DockerRegistry::Base
- Includes:
- Mod::Authorization, Mod::Request
- Defined in:
- lib/dapp/docker_registry/base.rb
Overview
Base
Direct Known Subclasses
Constant Summary collapse
- API_VERSION =
'v2'.freeze
Instance Attribute Summary collapse
-
#hostname_url ⇒ Object
Returns the value of attribute hostname_url.
-
#repo ⇒ Object
Returns the value of attribute repo.
-
#repo_suffix ⇒ Object
Returns the value of attribute repo_suffix.
Instance Method Summary collapse
- #image_delete(tag) ⇒ Object
- #image_history(tag) ⇒ Object
- #image_id(tag) ⇒ Object
- #image_labels(tag) ⇒ Object
- #image_parent_id(tag) ⇒ Object
-
#initialize(repo, hostname_url, repo_suffix) ⇒ Base
constructor
A new instance of Base.
- #repo_exist? ⇒ Boolean
- #tags ⇒ Object
Methods included from Mod::Authorization
#authorization_auth, #authorization_options, #authorization_token, #auths_section_from_docker_config, #parse_authenticate_header
Methods included from Mod::Request
#raw_request, #request, #url_available?
Constructor Details
#initialize(repo, hostname_url, repo_suffix) ⇒ Base
Returns a new instance of Base.
15 16 17 18 19 |
# File 'lib/dapp/docker_registry/base.rb', line 15 def initialize(repo, hostname_url, repo_suffix) self.repo = repo self.hostname_url = hostname_url self.repo_suffix = repo_suffix end |
Instance Attribute Details
#hostname_url ⇒ Object
Returns the value of attribute hostname_url.
12 13 14 |
# File 'lib/dapp/docker_registry/base.rb', line 12 def hostname_url @hostname_url end |
#repo ⇒ Object
Returns the value of attribute repo.
11 12 13 |
# File 'lib/dapp/docker_registry/base.rb', line 11 def repo @repo end |
#repo_suffix ⇒ Object
Returns the value of attribute repo_suffix.
13 14 15 |
# File 'lib/dapp/docker_registry/base.rb', line 13 def repo_suffix @repo_suffix end |
Instance Method Details
#image_delete(tag) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/dapp/docker_registry/base.rb', line 45 def image_delete(tag) image_blobs(tag).each { |hash| blob_delete(hash.values.first) } api_request(repo_suffix, "/manifests/#{image_digest(tag)}", method: :delete, expects: [202, 404], headers: { Accept: 'Accept: application/vnd.docker.distribution.manifest.v2+json' }) end |
#image_history(tag) ⇒ Object
53 54 55 56 |
# File 'lib/dapp/docker_registry/base.rb', line 53 def image_history(tag) response = manifest_v1(tag) JSON.load(response['history'].first['v1Compatibility']) end |
#image_id(tag) ⇒ Object
32 33 34 35 |
# File 'lib/dapp/docker_registry/base.rb', line 32 def image_id(tag) response = manifest_v2(tag) response['config']['digest'] if response['schemaVersion'] == 2 end |
#image_labels(tag) ⇒ Object
41 42 43 |
# File 'lib/dapp/docker_registry/base.rb', line 41 def image_labels(tag) image_history(tag)['config']['Labels'] end |
#image_parent_id(tag) ⇒ Object
37 38 39 |
# File 'lib/dapp/docker_registry/base.rb', line 37 def image_parent_id(tag) image_history(tag)['container_config']['Image'] end |
#repo_exist? ⇒ Boolean
21 22 23 |
# File 'lib/dapp/docker_registry/base.rb', line 21 def repo_exist? .any? end |
#tags ⇒ Object
25 26 27 28 29 30 |
# File 'lib/dapp/docker_registry/base.rb', line 25 def @tags ||= api_request(repo_suffix, 'tags/list')['tags'] || [] rescue Error::Registry => e raise Exception::Registry, code: :no_such_dimg, data: { registry: api_url } if e.net_status[:code] == :page_not_found raise end |