Class: UffizziCore::ComposeFile::Parsers::Services::VolumesParserService

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

Constant Summary collapse

HOST_VOLUME_TYPE =
:host
NAMED_VOLUME_TYPE =
:named
ANONYMOUS_VOLUME_TYPE =
:anonymous
READONLY_OPTION =
'ro'
READ_WRITE_OPTION =
'rw'

Class Method Summary collapse

Class Method Details

.parse(volumes, additional_data) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/services/uffizzi_core/compose_file/parsers/services/volumes_parser_service.rb', line 11

def parse(volumes, additional_data)
  return [] if volumes.blank?

  if volumes.is_a?(String)
    raise UffizziCore::ComposeFile::ParseError, I18n.t('compose.volumes_should_be_array', volumes: volumes)
  end

  volumes.map do |volume|
    volume_data = case volume
                  when String
                    process_short_syntax(volume, additional_data)
                  when Hash
                    process_long_syntax(volume, additional_data)
                  else
                    raise UffizziCore::ComposeFile::ParseError, I18n.t('compose.invalid_type', option: :volumes)
    end

    volume_data
  end.uniq
end