Class: UffizziCore::AzureRegistryClient
- Inherits:
-
Object
- Object
- UffizziCore::AzureRegistryClient
- Defined in:
- app/clients/uffizzi_core/azure_registry_client.rb
Defined Under Namespace
Classes: RequestResult
Instance Attribute Summary collapse
-
#connection ⇒ Object
Returns the value of attribute connection.
-
#registry_url ⇒ Object
Returns the value of attribute registry_url.
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
- #authentificated? ⇒ Boolean
-
#initialize(registry_url:, username:, password:) ⇒ AzureRegistryClient
constructor
A new instance of AzureRegistryClient.
- #manifests(image:, tag:) ⇒ Object
- #oauth2_token ⇒ Object
Constructor Details
#initialize(registry_url:, username:, password:) ⇒ AzureRegistryClient
Returns a new instance of AzureRegistryClient.
6 7 8 9 10 |
# File 'app/clients/uffizzi_core/azure_registry_client.rb', line 6 def initialize(registry_url:, username:, password:) @registry_url = registry_url @connection = build_connection(registry_url, username, password) @token = oauth2_token&.result&.access_token end |
Instance Attribute Details
#connection ⇒ Object
Returns the value of attribute connection.
4 5 6 |
# File 'app/clients/uffizzi_core/azure_registry_client.rb', line 4 def connection @connection end |
#registry_url ⇒ Object
Returns the value of attribute registry_url.
4 5 6 |
# File 'app/clients/uffizzi_core/azure_registry_client.rb', line 4 def registry_url @registry_url end |
#token ⇒ Object
Returns the value of attribute token.
4 5 6 |
# File 'app/clients/uffizzi_core/azure_registry_client.rb', line 4 def token @token end |
Instance Method Details
#authentificated? ⇒ Boolean
28 29 30 |
# File 'app/clients/uffizzi_core/azure_registry_client.rb', line 28 def authentificated? token.present? end |
#manifests(image:, tag:) ⇒ Object
12 13 14 15 16 17 |
# File 'app/clients/uffizzi_core/azure_registry_client.rb', line 12 def manifests(image:, tag:) url = "/v2/#{image}/manifests/#{tag}" response = connection.get(url) RequestResult.quiet.new(result: response.body, headers: response.headers) end |
#oauth2_token ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'app/clients/uffizzi_core/azure_registry_client.rb', line 19 def oauth2_token service = URI.parse(registry_url).hostname url = "/oauth2/token?service=#{service}" response = connection.get(url, {}) RequestResult.new(result: response.body) end |