Class: UffizziCore::ComposeFile::GithubDependenciesService

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

Constant Summary collapse

ENV_FILE_TYPE =
'env_file'
CONFIG_TYPE =
'config'
VOLUME_TYPE =
'volume'

Class Method Summary collapse

Class Method Details

.build_source_path(compose_path, dependency_path, repository_id, branch) ⇒ Object



39
40
41
42
43
44
45
# File 'app/services/uffizzi_core/compose_file/github_dependencies_service.rb', line 39

def build_source_path(compose_path, dependency_path, repository_id, branch)
  prepared_compose_path = Pathname.new(compose_path).basename.to_s
  base_source = "#{prepared_compose_path}/#{dependency_path}"
  return base_source if repository_id.blank?

  "#{repository_id}/#{branch}/#{base_source}"
end

.configs_dependencies(dependencies) ⇒ Object



31
32
33
# File 'app/services/uffizzi_core/compose_file/github_dependencies_service.rb', line 31

def configs_dependencies(dependencies)
  dependencies.select { |dependency| dependency[:type] == CONFIG_TYPE }
end

.configs_dependencies_for_container(dependencies, container_name) ⇒ Object



23
24
25
# File 'app/services/uffizzi_core/compose_file/github_dependencies_service.rb', line 23

def configs_dependencies_for_container(dependencies, container_name)
  configs_dependencies(dependencies).select { |dependency| dependency[:container_name] == container_name }
end

.content(dependency) ⇒ Object



15
16
17
# File 'app/services/uffizzi_core/compose_file/github_dependencies_service.rb', line 15

def content(dependency)
  Base64.decode64(dependency[:content])
end

.env_file_dependencies_for_container(dependencies, container_name) ⇒ Object



19
20
21
# File 'app/services/uffizzi_core/compose_file/github_dependencies_service.rb', line 19

def env_file_dependencies_for_container(dependencies, container_name)
  dependencies.select { |dependency| dependency[:type] == ENV_FILE_TYPE && dependency[:container_name] == container_name }
end

.filename(dependency) ⇒ Object



9
10
11
12
13
# File 'app/services/uffizzi_core/compose_file/github_dependencies_service.rb', line 9

def filename(dependency)
  pathname = Pathname.new(dependency[:path])

  pathname.basename.to_s
end

.host_volumes_dependencies_for_container(dependencies, container_name) ⇒ Object



27
28
29
# File 'app/services/uffizzi_core/compose_file/github_dependencies_service.rb', line 27

def host_volumes_dependencies_for_container(dependencies, container_name)
  dependencies.select { |dependency| dependency[:type] == VOLUME_TYPE && dependency[:container_name] == container_name }
end

.select_dependencies_by_type(dependencies, type) ⇒ Object



35
36
37
# File 'app/services/uffizzi_core/compose_file/github_dependencies_service.rb', line 35

def select_dependencies_by_type(dependencies, type)
  dependencies.select { |dependency| dependency[:type].to_s == type.to_s }
end