Class: UffizziCore::ComposeFile::ServicesOptions::ImageService

Inherits:
Object
  • Object
show all
Defined in:
app/services/uffizzi_core/compose_file/services_options/image_service.rb

Class Method Summary collapse

Class Method Details

.parse(image) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/services/uffizzi_core/compose_file/services_options/image_service.rb', line 5

def parse(image)
  return {} if image.blank?

  image_parts = image.downcase.split(':')
  raise UffizziCore::ComposeFile::ParseError, I18n.t('compose.invalid_image_value', value: image) if image_parts.count > 2

  image_name, tag = image_parts
  tag = Settings.compose.default_tag if tag.blank?
  raise UffizziCore::ComposeFile::ParseError, I18n.t('compose.invalid_image_value', value: image) if image_name.blank?

  if valid_image_url?(image_name)
    url, namespace, name = parse_image_url(image_name)
  else
    namespace, name = parse_docker_hub_image(image_name)
  end

  {
    registry_url: url,
    namespace: namespace,
    name: name,
    tag: tag,
  }
end