Module: UffizziCore::ComposeFileService
- Defined in:
- app/services/uffizzi_core/compose_file_service.rb
Class Method Summary collapse
- .build_template_attributes(compose_data, source, credentials, project, compose_dependencies = [], compose_repositories = []) ⇒ Object
- .containers_credentials(compose_data, credentials) ⇒ Object
- .create(params, kind) ⇒ Object
- .has_secret?(compose_file, secret) ⇒ Boolean
- .parse(compose_content, compose_payload = {}) ⇒ Object
- .secrets_valid?(compose_file, secrets) ⇒ Boolean
- .update(compose_file, params) ⇒ Object
- .update_secret!(compose_file, secret) ⇒ Object
Class Method Details
.build_template_attributes(compose_data, source, credentials, project, compose_dependencies = [], compose_repositories = []) ⇒ Object
38 39 40 41 42 |
# File 'app/services/uffizzi_core/compose_file_service.rb', line 38 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 |
.containers_credentials(compose_data, credentials) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/services/uffizzi_core/compose_file_service.rb', line 44 def containers_credentials(compose_data, credentials) containers = compose_data[:containers] detected_credentials = containers.map do |container| UffizziCore::ComposeFile::ContainerService.credential_for_container(container, credentials) end result = [] detected_credentials.compact .group_by { |credential| credential[:id] } .each_pair { |_id, value| result << value.first } result end |
.create(params, kind) ⇒ Object
5 6 7 8 9 |
# File 'app/services/uffizzi_core/compose_file_service.rb', line 5 def create(params, kind) compose_file_form = create_compose_form(params, kind) process_compose_file(compose_file_form, params) end |
.has_secret?(compose_file, secret) ⇒ Boolean
57 58 59 60 61 |
# File 'app/services/uffizzi_core/compose_file_service.rb', line 57 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
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/services/uffizzi_core/compose_file_service.rb', line 17 def parse(compose_content, compose_payload = {}) compose_data = load_compose_data(compose_content) (compose_data) configs_data = UffizziCore::ComposeFile::ConfigsOptionsService.parse(compose_data['configs']) secrets_data = UffizziCore::ComposeFile::SecretsOptionsService.parse(compose_data['secrets']) containers_data = UffizziCore::ComposeFile::ServicesOptionsService.parse(compose_data['services'], configs_data, secrets_data, compose_payload) continuous_preview_option = UffizziCore::ComposeFile::ConfigOptionService.continuous_preview_option(compose_data) continuous_preview_data = UffizziCore::ComposeFile::ContinuousPreviewOptionsService.parse(continuous_preview_option) ingress_option = UffizziCore::ComposeFile::ConfigOptionService.ingress_option(compose_data) ingress_data = UffizziCore::ComposeFile::IngressOptionsService.parse(ingress_option, compose_data['services']) { containers: containers_data, ingress: ingress_data, continuous_preview: continuous_preview_data, } end |
.secrets_valid?(compose_file, secrets) ⇒ Boolean
77 78 79 80 81 82 83 |
# File 'app/services/uffizzi_core/compose_file_service.rb', line 77 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
11 12 13 14 15 |
# File 'app/services/uffizzi_core/compose_file_service.rb', line 11 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
63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'app/services/uffizzi_core/compose_file_service.rb', line 63 def update_secret!(compose_file, secret) compose_file.template.payload['containers_attributes'].map do |container| if UffizziCore::ComposeFile::ContainerService.has_secret?(container, secret) container = UffizziCore::ComposeFile::ContainerService.update_secret(container, secret) end container end compose_file.template.save! compose_file end |