Class: UffizziCore::ContainerRegistry::AmazonService

Inherits:
Object
  • Object
show all
Defined in:
app/services/uffizzi_core/container_registry/amazon_service.rb

Class Method Summary collapse

Class Method Details

.access_token(credential) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'app/services/uffizzi_core/container_registry/amazon_service.rb', line 27

def access_token(credential)
  response = client(credential).authorization_token
  base64_data = response.authorization_data[0].authorization_token
  token_string = Base64.decode64(base64_data)
  token_items = token_string.split(':')
  token_items.pop
rescue Aws::ECR::Errors::UnrecognizedClientException, Aws::ECR::Errors::InvalidSignatureException
  ''
end

.credential_correct?(credential) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'app/services/uffizzi_core/container_registry/amazon_service.rb', line 23

def credential_correct?(credential)
  access_token(credential).present?
end

.digest(credential, image, tag) ⇒ Object



5
6
7
8
9
10
# File 'app/services/uffizzi_core/container_registry/amazon_service.rb', line 5

def digest(credential, image, tag)
  response = client(credential).batch_get_image(image: image, tag: tag)
  response.images[0].image_id.image_digest
rescue StandardError
  nil
end

.get_region_from_registry_url(url) ⇒ Object



12
13
14
15
16
17
# File 'app/services/uffizzi_core/container_registry/amazon_service.rb', line 12

def get_region_from_registry_url(url)
  parsed_url = URI.parse(url)
  host = parsed_url.host
  parsed_host = host.split('.')
  parsed_host[3]
end

.image_available?(credential, _image_data) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'app/services/uffizzi_core/container_registry/amazon_service.rb', line 19

def image_available?(credential, _image_data)
  credential.present?
end