Class: UffizziCore::ComposeFile::Parsers::Services::ImageParserService

Inherits:
Object
  • Object
show all
Defined in:
app/services/uffizzi_core/compose_file/parsers/services/image_parser_service.rb

Constant Summary collapse

DEFAULT_TAG =
Settings.compose.default_tag

Class Method Summary collapse

Class Method Details

.parse(value) ⇒ Object



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/parsers/services/image_parser_service.rb', line 8

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

  parsed_image = DockerDistribution::Normalize.parse_docker_ref(value)
  image_path = parsed_image.path
  namespace, name = get_namespace_and_name(image_path)
  full_image_name = "#{[parsed_image.domain, parsed_image.path].compact.join('/')}:#{parsed_image.tag}"

  {
    registry_url: parsed_image.domain,
    namespace: namespace,
    name: name,
    tag: parsed_image.tag,
    full_image_name: full_image_name,
  }
rescue DockerDistribution::NameContainsUppercase
  raise_parse_error(I18n.t('compose.image_name_contains_uppercase_value', value: value))
rescue DockerDistribution::ReferenceInvalidFormat, DockerDistribution::ParseNormalizedNamedError
  raise_parse_error(I18n.t('compose.invalid_image_value', value: value))
end