Class: UffizziCore::ComposeFile::Builders::VariablesBuilderService

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project) ⇒ VariablesBuilderService

Returns a new instance of VariablesBuilderService.



8
9
10
# File 'app/services/uffizzi_core/compose_file/builders/variables_builder_service.rb', line 8

def initialize(project)
  @project = project
end

Instance Attribute Details

#projectObject

Returns the value of attribute project.



4
5
6
# File 'app/services/uffizzi_core/compose_file/builders/variables_builder_service.rb', line 4

def project
  @project
end

Instance Method Details

#build_attributes(variables_data, dependencies) ⇒ Object



12
13
14
15
16
17
# File 'app/services/uffizzi_core/compose_file/builders/variables_builder_service.rb', line 12

def build_attributes(variables_data, dependencies)
  variables = variables_data
  variables_from_dependencies = variables_from_dependencies(dependencies)

  variables + variables_from_dependencies
end

#build_secret_attributes(secrets) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'app/services/uffizzi_core/compose_file/builders/variables_builder_service.rb', line 19

def build_secret_attributes(secrets)
  project_secrets = project.secrets || []

  secrets.uniq.map do |secret|
    detected_secret = project_secrets.detect { |project_secret| project_secret['name'] == secret }
    error_message = I18n.t('compose.project_secret_not_found', secret: secret)
    raise UffizziCore::ComposeFile::SecretsError, error_message if detected_secret.nil?

    build_variable(detected_secret['name'], detected_secret['value'])
  end
end