Class: UffizziCore::GithubContainerRegistryClient

Inherits:
Object
  • Object
show all
Defined in:
app/clients/uffizzi_core/github_container_registry_client.rb,
app/clients/uffizzi_core/github_container_registry_client/request_result.rb

Defined Under Namespace

Classes: RequestResult

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(registry_url:, username:, password:) ⇒ GithubContainerRegistryClient

Returns a new instance of GithubContainerRegistryClient.



6
7
8
9
10
11
# File 'app/clients/uffizzi_core/github_container_registry_client.rb', line 6

def initialize(registry_url:, username:, password:)
  @registry_url = registry_url
  @username = username
  @password = password
  @token = access_token&.result&.token
end

Instance Attribute Details

#registry_urlObject

Returns the value of attribute registry_url.



4
5
6
# File 'app/clients/uffizzi_core/github_container_registry_client.rb', line 4

def registry_url
  @registry_url
end

#tokenObject

Returns the value of attribute token.



4
5
6
# File 'app/clients/uffizzi_core/github_container_registry_client.rb', line 4

def token
  @token
end

Instance Method Details

#access_tokenObject



13
14
15
16
17
18
19
20
# File 'app/clients/uffizzi_core/github_container_registry_client.rb', line 13

def access_token
  service = URI.parse(registry_url).hostname
  url = "/token?service=#{service}"

  response = connection.get(url, {})

  RequestResult.new(result: response.body)
end

#authentificated?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'app/clients/uffizzi_core/github_container_registry_client.rb', line 22

def authentificated?
  token.present?
end

#manifests(image:, tag:) ⇒ Object



26
27
28
29
30
31
# File 'app/clients/uffizzi_core/github_container_registry_client.rb', line 26

def manifests(image:, tag:)
  url = "/v2/#{@username}/#{image}/manifests/#{tag}"
  response = token_connection.get(url)

  RequestResult.quiet.new(result: response.body, headers: response.headers)
end