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'

Class Method Summary collapse

Class Method Details

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



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

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



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

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

.configs_dependencies_for_container(dependencies, container_name) ⇒ Object



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

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

.content(dependency) ⇒ Object



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

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

.env_file_dependencies_for_container(dependencies, container_name) ⇒ Object



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

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



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

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

  pathname.basename.to_s
end