Class: UffizziCore::ComposeFileService
Class Method Summary
collapse
-
.build_template_attributes(compose_data, source, credentials, project, compose_dependencies = [], compose_repositories = []) ⇒ Object
-
.create(params, kind) ⇒ Object
-
.create_temporary_compose(resource_project, current_user, compose_file_params, dependencies) ⇒ Object
-
.has_secret?(compose_file, secret) ⇒ Boolean
-
.parse(compose_content, compose_payload = {}) ⇒ Object
-
.parse_ingress(ingress_option, compose_data) ⇒ Object
-
.secrets_valid?(compose_file, secrets) ⇒ Boolean
-
.update(compose_file, params) ⇒ Object
-
.update_secret!(compose_file, secret) ⇒ Object
ci_module, ci_session, controller_settings_service, deployment_memory_module, domain_module, find_build_parser_module, find_ingress_parser_module, find_volume_parser_module, notification_module, password_protection_module, template_memory_module, user_access_module
Class Method Details
.build_template_attributes(compose_data, source, credentials, project, compose_dependencies = [], compose_repositories = []) ⇒ Object
56
57
58
59
60
|
# File 'app/services/uffizzi_core/compose_file_service.rb', line 56
def build_template_attributes(compose_data, source, credentials, project, compose_dependencies = [], compose_repositories = [])
builder = UffizziCore::ComposeFile::Builders::TemplateBuilderService.new(credentials, project, compose_repositories)
builder.build_attributes(compose_data, compose_dependencies, source)
end
|
.create(params, kind) ⇒ Object
7
8
9
10
11
|
# File 'app/services/uffizzi_core/compose_file_service.rb', line 7
def create(params, kind)
compose_file_form = create_compose_form(params, kind)
process_compose_file(compose_file_form, params)
end
|
.create_temporary_compose(resource_project, current_user, compose_file_params, dependencies) ⇒ Object
105
106
107
108
109
110
|
# File 'app/services/uffizzi_core/compose_file_service.rb', line 105
def create_temporary_compose(resource_project, current_user, compose_file_params, dependencies)
create_params = { project: resource_project, user: current_user, compose_file_params: compose_file_params,
dependencies: dependencies || [] }
kind = UffizziCore::ComposeFile.kind.temporary
UffizziCore::ComposeFileService.create(create_params, kind)
end
|
.has_secret?(compose_file, secret) ⇒ Boolean
62
63
64
65
66
|
# File 'app/services/uffizzi_core/compose_file_service.rb', line 62
def has_secret?(compose_file, secret)
containers = compose_file.template.payload['containers_attributes']
containers.any? { |container| UffizziCore::ComposeFile::ContainerService.has_secret?(container, secret) }
end
|
.parse(compose_content, compose_payload = {}) ⇒ Object
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
|
# File 'app/services/uffizzi_core/compose_file_service.rb', line 19
def parse(compose_content, compose_payload = {})
compose_data = load_compose_data(compose_content)
check_config_options_format(compose_data)
configs_data = UffizziCore::ComposeFile::Parsers::ConfigsParserService.parse(compose_data['configs'])
secrets_data = UffizziCore::ComposeFile::Parsers::SecretsParserService.parse(compose_data['secrets'])
named_volume_names = UffizziCore::ComposeFile::Parsers::NamedVolumesParserService.parse(compose_data['volumes'])
containers_data = UffizziCore::ComposeFile::Parsers::ServicesParserService.parse(
compose_data['services'],
configs_data,
secrets_data,
compose_payload,
named_volume_names,
)
continuous_preview_option = UffizziCore::ComposeFile::ConfigOptionService.continuous_preview_option(compose_data)
continuous_preview_data = UffizziCore::ComposeFile::Parsers::ContinuousPreviewParserService.parse(continuous_preview_option)
ingress_option = UffizziCore::ComposeFile::ConfigOptionService.ingress_option(compose_data)
ingress_data = parse_ingress(ingress_option, compose_data)
{
containers: containers_data,
ingress: ingress_data,
continuous_preview: continuous_preview_data,
}
end
|
.parse_ingress(ingress_option, compose_data) ⇒ Object
45
46
47
48
49
50
51
52
53
54
|
# File 'app/services/uffizzi_core/compose_file_service.rb', line 45
def parse_ingress(ingress_option, compose_data)
ingress_parser_module = find_ingress_parser_module
unless ingress_parser_module
return UffizziCore::ComposeFile::Parsers::IngressParserService.parse(ingress_option,
compose_data['services'])
end
ingress_parser_module.parse(ingress_option, compose_data['services'])
end
|
.secrets_valid?(compose_file, secrets) ⇒ Boolean
97
98
99
100
101
102
103
|
# File 'app/services/uffizzi_core/compose_file_service.rb', line 97
def secrets_valid?(compose_file, secrets)
secret_names = secrets.pluck('name')
compose_file.template.payload['containers_attributes'].all? do |container|
container['secret_variables'].all? { |secret| secret_names.include?(secret['name']) }
end
end
|
.update(compose_file, params) ⇒ Object
13
14
15
16
17
|
# File 'app/services/uffizzi_core/compose_file_service.rb', line 13
def update(compose_file, params)
compose_file_form = create_update_compose_form(compose_file, params)
process_compose_file(compose_file_form, params)
end
|
.update_secret!(compose_file, secret) ⇒ Object