Class: UffizziCore::ComposeFile::Builders::ContainerBuilderService

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(credentials, project, repositories = []) ⇒ ContainerBuilderService

Returns a new instance of ContainerBuilderService.



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

def initialize(credentials, project, repositories = [])
  @credentials = credentials
  @project = project
  @repositories = repositories
end

Instance Attribute Details

#credentialsObject

Returns the value of attribute credentials.



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

def credentials
  @credentials
end

#projectObject

Returns the value of attribute project.



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

def project
  @project
end

#repositoriesObject

Returns the value of attribute repositories.



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

def repositories
  @repositories
end

Instance Method Details

#build_attributes(container_data, ingress_data, continuous_preview_global_data, compose_dependencies) ⇒ Object

rubocop:disable Metrics/PerceivedComplexity



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'app/services/uffizzi_core/compose_file/builders/container_builder_service.rb', line 13

def build_attributes(container_data, ingress_data, continuous_preview_global_data, compose_dependencies)
  image_data = container_data[:image] || {}
  build_data = container_data[:build] || {}
  environment = container_data[:environment] || []
  deploy_data = container_data[:deploy] || {}
  configs_data = container_data[:configs] || []
  secrets = container_data[:secrets] || []
  container_name = container_data[:container_name]
  healthcheck_data = container_data[:healthcheck] || {}
  volumes_data = container_data[:volumes] || []

  github_deps_service = UffizziCore::ComposeFile::GithubDependenciesService

  env_file_dependencies = github_deps_service.env_file_dependencies_for_container(compose_dependencies, container_name)
  configs_dependencies = github_deps_service.configs_dependencies_for_container(compose_dependencies, container_name)
  host_volumes_dependencies = github_deps_service.host_volumes_dependencies_for_container(compose_dependencies, container_name)
  is_ingress = ingress_container?(container_name, ingress_data)
  repo_attributes = repo_attributes(container_data, continuous_preview_global_data)
  additional_subdomains = is_ingress ? ingress_data.fetch(:additional_subdomains, []) : []
  memory_limit = memory_limit(deploy_data)

  {
    tag: tag(image_data, repo_attributes),
    port: port(container_name, ingress_data),
    full_image_name: full_image_name(image_data, build_data, repo_attributes),
    image: image(container_data, image_data, build_data, credentials),
    public: is_ingress,
    entrypoint: entrypoint(container_data),
    command: command(container_data),
    variables: variables(environment, env_file_dependencies),
    secret_variables: secret_variables(secrets),
    memory_limit: memory_limit,
    memory_request: memory_request(memory_limit),
    repo_attributes: repo_attributes,
    continuously_deploy: continuously_deploy(deploy_data),
    receive_incoming_requests: is_ingress,
    container_config_files_attributes: container_config_files_attributes(configs_data, configs_dependencies),
    service_name: container_name,
    name: container_name,
    healthcheck: healthcheck_data,
    volumes: volumes_data,
    additional_subdomains: additional_subdomains,
    container_host_volume_files_attributes: container_host_volume_files_attributes(volumes_data, host_volumes_dependencies),
  }
end