Class: UffizziCore::ProjectService
- Inherits:
-
Object
- Object
- UffizziCore::ProjectService
- Defined in:
- app/services/uffizzi_core/project_service.rb
Class Method Summary collapse
- .add_users_to_project!(project, account) ⇒ Object
- .update_compose_secret_errors(project, secret) ⇒ Object
- .update_compose_secrets(project) ⇒ Object
Class Method Details
.add_users_to_project!(project, account) ⇒ Object
39 40 41 42 43 44 45 |
# File 'app/services/uffizzi_core/project_service.rb', line 39 def add_users_to_project!(project, account) user_projects = account.memberships.map do |membership| { project: project, user: membership.user, role: membership.role } end UffizziCore::UserProject.create!(user_projects) end |
.update_compose_secret_errors(project, secret) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/services/uffizzi_core/project_service.rb', line 24 def update_compose_secret_errors(project, secret) compose_file = project.compose_file return if compose_file.nil? return unless UffizziCore::ComposeFileService.has_secret?(compose_file, secret) = I18n.t('compose.project_secret_not_found', secret: secret['name']) compose_file_errors = compose_file.payload['errors'] || {} secrets_errors = compose_file_errors[UffizziCore::ComposeFile::ErrorsService::SECRETS_ERROR_KEY].presence || [] new_secrets_errors = secrets_errors.append().uniq error = { UffizziCore::ComposeFile::ErrorsService::SECRETS_ERROR_KEY => new_secrets_errors } new_errors = compose_file_errors.merge(error) UffizziCore::ComposeFile::ErrorsService.update_compose_errors!(compose_file, new_errors, compose_file.content) end |
.update_compose_secrets(project) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/services/uffizzi_core/project_service.rb', line 5 def update_compose_secrets(project) compose_file = project.compose_file return if compose_file&.template.nil? project.secrets.each do |secret| if UffizziCore::ComposeFileService.has_secret?(compose_file, secret) UffizziCore::ComposeFileService.update_secret!(compose_file, secret) end end return unless UffizziCore::ComposeFileService.secrets_valid?(compose_file, project.secrets) secrets_error_key = UffizziCore::ComposeFile::ErrorsService::SECRETS_ERROR_KEY return unless UffizziCore::ComposeFile::ErrorsService.has_error?(compose_file, secrets_error_key) UffizziCore::ComposeFile::ErrorsService.reset_error!(compose_file, secrets_error_key) compose_file.set_valid! unless UffizziCore::ComposeFile::ErrorsService.has_errors?(compose_file) end |