uffizzi_core 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +201 -0
- data/README.md +46 -0
- data/Rakefile +31 -0
- data/app/assets/config/uffizzi_core_manifest.js +1 -0
- data/app/assets/stylesheets/uffizzi_core/application.css +15 -0
- data/app/clients/uffizzi_core/amazon_registry_client.rb +18 -0
- data/app/clients/uffizzi_core/azure_registry_client/request_result.rb +5 -0
- data/app/clients/uffizzi_core/azure_registry_client.rb +42 -0
- data/app/clients/uffizzi_core/controller_client/request_result.rb +5 -0
- data/app/clients/uffizzi_core/controller_client.rb +106 -0
- data/app/clients/uffizzi_core/docker_hub_client/request_result.rb +7 -0
- data/app/clients/uffizzi_core/docker_hub_client.rb +139 -0
- data/app/clients/uffizzi_core/github/app_client.rb +19 -0
- data/app/clients/uffizzi_core/github/installation_client.rb +11 -0
- data/app/clients/uffizzi_core/github/user_client.rb +51 -0
- data/app/clients/uffizzi_core/google_registry_client/request_result.rb +5 -0
- data/app/clients/uffizzi_core/google_registry_client.rb +42 -0
- data/app/contexts/uffizzi_core/base_context.rb +12 -0
- data/app/contexts/uffizzi_core/project_context.rb +13 -0
- data/app/contexts/uffizzi_core/webhooks_context.rb +9 -0
- data/app/controllers/concerns/uffizzi_core/auth_management.rb +23 -0
- data/app/controllers/concerns/uffizzi_core/authorization_concern.rb +38 -0
- data/app/controllers/concerns/uffizzi_core/dependency_injection_concern.rb +19 -0
- data/app/controllers/uffizzi_core/api/cli/v1/account/application_controller.rb +7 -0
- data/app/controllers/uffizzi_core/api/cli/v1/account/credentials_controller.rb +55 -0
- data/app/controllers/uffizzi_core/api/cli/v1/application_controller.rb +5 -0
- data/app/controllers/uffizzi_core/api/cli/v1/projects/application_controller.rb +11 -0
- data/app/controllers/uffizzi_core/api/cli/v1/projects/compose_files_controller.rb +93 -0
- data/app/controllers/uffizzi_core/api/cli/v1/projects/deployments/activity_items_controller.rb +36 -0
- data/app/controllers/uffizzi_core/api/cli/v1/projects/deployments/application_controller.rb +7 -0
- data/app/controllers/uffizzi_core/api/cli/v1/projects/deployments/containers/application_controller.rb +8 -0
- data/app/controllers/uffizzi_core/api/cli/v1/projects/deployments/containers/logs_controller.rb +27 -0
- data/app/controllers/uffizzi_core/api/cli/v1/projects/deployments/containers_controller.rb +24 -0
- data/app/controllers/uffizzi_core/api/cli/v1/projects/deployments/events_controller.rb +29 -0
- data/app/controllers/uffizzi_core/api/cli/v1/projects/deployments_controller.rb +148 -0
- data/app/controllers/uffizzi_core/api/cli/v1/projects/secrets_controller.rb +69 -0
- data/app/controllers/uffizzi_core/api/cli/v1/projects_controller.rb +19 -0
- data/app/controllers/uffizzi_core/api/cli/v1/sessions_controller.rb +43 -0
- data/app/controllers/uffizzi_core/application_controller.rb +51 -0
- data/app/errors/uffizzi_core/compose_file/build_error.rb +4 -0
- data/app/errors/uffizzi_core/compose_file/credential_error.rb +4 -0
- data/app/errors/uffizzi_core/compose_file/not_found_error.rb +4 -0
- data/app/errors/uffizzi_core/compose_file/parse_error.rb +4 -0
- data/app/errors/uffizzi_core/compose_file/secrets_error.rb +4 -0
- data/app/errors/uffizzi_core/deployment_not_found_error.rb +10 -0
- data/app/forms/uffizzi_core/api/cli/v1/account/credential/create_form.rb +26 -0
- data/app/forms/uffizzi_core/api/cli/v1/compose_file/check_credentials_form.rb +21 -0
- data/app/forms/uffizzi_core/api/cli/v1/compose_file/cli_form.rb +39 -0
- data/app/forms/uffizzi_core/api/cli/v1/compose_file/create_form.rb +13 -0
- data/app/forms/uffizzi_core/api/cli/v1/compose_file/template_form.rb +44 -0
- data/app/forms/uffizzi_core/api/cli/v1/compose_file/update_form.rb +9 -0
- data/app/forms/uffizzi_core/api/cli/v1/config_file/create_form.rb +11 -0
- data/app/forms/uffizzi_core/api/cli/v1/deployment/create_form.rb +91 -0
- data/app/forms/uffizzi_core/api/cli/v1/project/delete_secret_form.rb +27 -0
- data/app/forms/uffizzi_core/api/cli/v1/project/update_form.rb +40 -0
- data/app/forms/uffizzi_core/api/cli/v1/session_create_form.rb +29 -0
- data/app/forms/uffizzi_core/api/cli/v1/template/create_form.rb +65 -0
- data/app/forms/uffizzi_core/application_form.rb +11 -0
- data/app/forms/uffizzi_core/application_form_without_active_record.rb +17 -0
- data/app/forms/uffizzi_core/mass_assignment_control_concern.rb +22 -0
- data/app/helpers/uffizzi_core/application_helper.rb +6 -0
- data/app/jobs/uffizzi_core/account/create_credential_job.rb +10 -0
- data/app/jobs/uffizzi_core/activity_item/docker/update_digest_job.rb +11 -0
- data/app/jobs/uffizzi_core/application_job.rb +7 -0
- data/app/jobs/uffizzi_core/config_file/apply_job.rb +31 -0
- data/app/jobs/uffizzi_core/credential/docker_hub/create_webhook_job.rb +15 -0
- data/app/jobs/uffizzi_core/deployment/create_credential_job.rb +32 -0
- data/app/jobs/uffizzi_core/deployment/create_credentials_job.rb +17 -0
- data/app/jobs/uffizzi_core/deployment/create_job.rb +15 -0
- data/app/jobs/uffizzi_core/deployment/create_webhooks_job.rb +13 -0
- data/app/jobs/uffizzi_core/deployment/delete_credential_job.rb +13 -0
- data/app/jobs/uffizzi_core/deployment/delete_job.rb +11 -0
- data/app/jobs/uffizzi_core/deployment/deploy_containers_job.rb +27 -0
- data/app/jobs/uffizzi_core/deployment/manage_deploy_activity_item_job.rb +19 -0
- data/app/jobs/uffizzi_core/deployment/send_github_preview_message_job.rb +13 -0
- data/app/lib/uffizzi_core/rbac/user_access_service.rb +21 -0
- data/app/mailers/uffizzi_core/application_mailer.rb +8 -0
- data/app/models/concerns/uffizzi_core/hashid_concern.rb +25 -0
- data/app/models/concerns/uffizzi_core/state_machine_concern.rb +16 -0
- data/app/models/uffizzi_core/account.rb +101 -0
- data/app/models/uffizzi_core/activity_item/docker.rb +4 -0
- data/app/models/uffizzi_core/activity_item/github.rb +4 -0
- data/app/models/uffizzi_core/activity_item/memory_limit.rb +4 -0
- data/app/models/uffizzi_core/activity_item.rb +58 -0
- data/app/models/uffizzi_core/application_record.rb +7 -0
- data/app/models/uffizzi_core/build.rb +39 -0
- data/app/models/uffizzi_core/comment.rb +16 -0
- data/app/models/uffizzi_core/compose_file.rb +57 -0
- data/app/models/uffizzi_core/config_file.rb +24 -0
- data/app/models/uffizzi_core/container.rb +100 -0
- data/app/models/uffizzi_core/container_config_file.rb +8 -0
- data/app/models/uffizzi_core/continuous_preview.rb +4 -0
- data/app/models/uffizzi_core/coupon.rb +5 -0
- data/app/models/uffizzi_core/credential/amazon.rb +4 -0
- data/app/models/uffizzi_core/credential/azure.rb +4 -0
- data/app/models/uffizzi_core/credential/docker_hub.rb +4 -0
- data/app/models/uffizzi_core/credential/github.rb +4 -0
- data/app/models/uffizzi_core/credential/google.rb +4 -0
- data/app/models/uffizzi_core/credential.rb +64 -0
- data/app/models/uffizzi_core/database.rb +4 -0
- data/app/models/uffizzi_core/database_offering.rb +4 -0
- data/app/models/uffizzi_core/deployment.rb +77 -0
- data/app/models/uffizzi_core/event.rb +13 -0
- data/app/models/uffizzi_core/invitation.rb +27 -0
- data/app/models/uffizzi_core/membership.rb +16 -0
- data/app/models/uffizzi_core/payment.rb +11 -0
- data/app/models/uffizzi_core/price.rb +9 -0
- data/app/models/uffizzi_core/product.rb +11 -0
- data/app/models/uffizzi_core/project.rb +66 -0
- data/app/models/uffizzi_core/rating.rb +20 -0
- data/app/models/uffizzi_core/repo/amazon.rb +4 -0
- data/app/models/uffizzi_core/repo/azure.rb +4 -0
- data/app/models/uffizzi_core/repo/docker_hub.rb +4 -0
- data/app/models/uffizzi_core/repo/github.rb +4 -0
- data/app/models/uffizzi_core/repo/google.rb +4 -0
- data/app/models/uffizzi_core/repo.rb +39 -0
- data/app/models/uffizzi_core/role.rb +17 -0
- data/app/models/uffizzi_core/template.rb +19 -0
- data/app/models/uffizzi_core/user.rb +62 -0
- data/app/models/uffizzi_core/user_project.rb +14 -0
- data/app/policies/uffizzi_core/api/cli/v1/account/credentials_policy.rb +11 -0
- data/app/policies/uffizzi_core/api/cli/v1/projects/compose_files_policy.rb +15 -0
- data/app/policies/uffizzi_core/api/cli/v1/projects/deployments/activity_items_policy.rb +7 -0
- data/app/policies/uffizzi_core/api/cli/v1/projects/deployments/containers_policy.rb +7 -0
- data/app/policies/uffizzi_core/api/cli/v1/projects/deployments/events_policy.rb +7 -0
- data/app/policies/uffizzi_core/api/cli/v1/projects/deployments_policy.rb +23 -0
- data/app/policies/uffizzi_core/api/cli/v1/projects/secrets_policy.rb +15 -0
- data/app/policies/uffizzi_core/api/cli/v1/projects_policy.rb +7 -0
- data/app/policies/uffizzi_core/application_policy.rb +12 -0
- data/app/repositories/uffizzi_core/activity_item_repo.rb +9 -0
- data/app/repositories/uffizzi_core/basic_order_repo.rb +11 -0
- data/app/repositories/uffizzi_core/build_repo.rb +23 -0
- data/app/repositories/uffizzi_core/comment_repo.rb +11 -0
- data/app/repositories/uffizzi_core/compose_file_repo.rb +11 -0
- data/app/repositories/uffizzi_core/config_file_repo.rb +40 -0
- data/app/repositories/uffizzi_core/container_repo.rb +25 -0
- data/app/repositories/uffizzi_core/credential_repo.rb +36 -0
- data/app/repositories/uffizzi_core/deployment_repo.rb +23 -0
- data/app/repositories/uffizzi_core/event_repo.rb +9 -0
- data/app/repositories/uffizzi_core/membership_repo.rb +10 -0
- data/app/repositories/uffizzi_core/price_repo.rb +11 -0
- data/app/repositories/uffizzi_core/product_repo.rb +11 -0
- data/app/repositories/uffizzi_core/project_repo.rb +10 -0
- data/app/repositories/uffizzi_core/repo_repo.rb +10 -0
- data/app/repositories/uffizzi_core/template_repo.rb +87 -0
- data/app/repositories/uffizzi_core/usage_repo.rb +9 -0
- data/app/repositories/uffizzi_core/user_repo.rb +11 -0
- data/app/responders/uffizzi_core/json_responder.rb +13 -0
- data/app/serializers/uffizzi_core/api/cli/v1/account/credential_serializer.rb +9 -0
- data/app/serializers/uffizzi_core/api/cli/v1/project_serializer.rb +7 -0
- data/app/serializers/uffizzi_core/api/cli/v1/projects/compose_file_serializer.rb +7 -0
- data/app/serializers/uffizzi_core/api/cli/v1/projects/deployment_serializer/container_serializer.rb +23 -0
- data/app/serializers/uffizzi_core/api/cli/v1/projects/deployment_serializer/user_serializer.rb +11 -0
- data/app/serializers/uffizzi_core/api/cli/v1/projects/deployment_serializer.rb +74 -0
- data/app/serializers/uffizzi_core/api/cli/v1/projects/deployments/activity_item_serializer.rb +24 -0
- data/app/serializers/uffizzi_core/api/cli/v1/projects/deployments/container_serializer/container_config_file_serializer/config_file_serializer.rb +6 -0
- data/app/serializers/uffizzi_core/api/cli/v1/projects/deployments/container_serializer/container_config_file_serializer.rb +7 -0
- data/app/serializers/uffizzi_core/api/cli/v1/projects/deployments/container_serializer.rb +30 -0
- data/app/serializers/uffizzi_core/api/cli/v1/user_serializer/account_serializer.rb +5 -0
- data/app/serializers/uffizzi_core/api/cli/v1/user_serializer.rb +7 -0
- data/app/serializers/uffizzi_core/base_serializer.rb +7 -0
- data/app/serializers/uffizzi_core/controller/create_credential/credential_serializer.rb +17 -0
- data/app/serializers/uffizzi_core/controller/create_deployment/deployment_serializer.rb +5 -0
- data/app/serializers/uffizzi_core/controller/deploy_containers/container_serializer.rb +53 -0
- data/app/serializers/uffizzi_core/controller/deploy_containers/credential_serializer.rb +5 -0
- data/app/services/uffizzi_core/account_service.rb +21 -0
- data/app/services/uffizzi_core/activity_item_service.rb +98 -0
- data/app/services/uffizzi_core/amazon/credential_service.rb +31 -0
- data/app/services/uffizzi_core/amazon_service.rb +45 -0
- data/app/services/uffizzi_core/azure/credential_service.rb +18 -0
- data/app/services/uffizzi_core/cli/compose_file_service.rb +203 -0
- data/app/services/uffizzi_core/compose_file/builders/config_files_builder_service.rb +31 -0
- data/app/services/uffizzi_core/compose_file/builders/container_builder_service.rb +225 -0
- data/app/services/uffizzi_core/compose_file/builders/docker_repo_builder_service.rb +25 -0
- data/app/services/uffizzi_core/compose_file/builders/github_repo_builder_service.rb +59 -0
- data/app/services/uffizzi_core/compose_file/builders/template_builder_service.rb +45 -0
- data/app/services/uffizzi_core/compose_file/builders/variables_builder_service.rb +58 -0
- data/app/services/uffizzi_core/compose_file/config_files_service.rb +52 -0
- data/app/services/uffizzi_core/compose_file/config_option_service.rb +37 -0
- data/app/services/uffizzi_core/compose_file/configs_options_service.rb +26 -0
- data/app/services/uffizzi_core/compose_file/container_service.rb +64 -0
- data/app/services/uffizzi_core/compose_file/continuous_preview_options_service.rb +57 -0
- data/app/services/uffizzi_core/compose_file/dependencies_service.rb +55 -0
- data/app/services/uffizzi_core/compose_file/errors_service.rb +46 -0
- data/app/services/uffizzi_core/compose_file/github_dependencies_service.rb +38 -0
- data/app/services/uffizzi_core/compose_file/ingress_options_service.rb +49 -0
- data/app/services/uffizzi_core/compose_file/secrets_options_service.rb +28 -0
- data/app/services/uffizzi_core/compose_file/services_options/build_service.rb +93 -0
- data/app/services/uffizzi_core/compose_file/services_options/command_service.rb +18 -0
- data/app/services/uffizzi_core/compose_file/services_options/configs_service.rb +51 -0
- data/app/services/uffizzi_core/compose_file/services_options/deploy_service.rb +44 -0
- data/app/services/uffizzi_core/compose_file/services_options/entrypoint_service.rb +18 -0
- data/app/services/uffizzi_core/compose_file/services_options/env_file_service.rb +34 -0
- data/app/services/uffizzi_core/compose_file/services_options/environment_service.rb +20 -0
- data/app/services/uffizzi_core/compose_file/services_options/image_service.rb +89 -0
- data/app/services/uffizzi_core/compose_file/services_options/secrets_service.rb +35 -0
- data/app/services/uffizzi_core/compose_file/services_options_service.rb +55 -0
- data/app/services/uffizzi_core/compose_file/template_service.rb +55 -0
- data/app/services/uffizzi_core/compose_file/update_service.rb +29 -0
- data/app/services/uffizzi_core/compose_file/variables_service.rb +25 -0
- data/app/services/uffizzi_core/compose_file_service.rb +33 -0
- data/app/services/uffizzi_core/container_service.rb +57 -0
- data/app/services/uffizzi_core/controller_service.rb +80 -0
- data/app/services/uffizzi_core/credential_service.rb +44 -0
- data/app/services/uffizzi_core/deployment_service.rb +274 -0
- data/app/services/uffizzi_core/docker_hub/credential_service.rb +15 -0
- data/app/services/uffizzi_core/docker_hub_service.rb +77 -0
- data/app/services/uffizzi_core/github/app_service.rb +51 -0
- data/app/services/uffizzi_core/github/credential_service.rb +124 -0
- data/app/services/uffizzi_core/github/message_service.rb +20 -0
- data/app/services/uffizzi_core/github_service.rb +28 -0
- data/app/services/uffizzi_core/google/credential_service.rb +18 -0
- data/app/services/uffizzi_core/logs_service.rb +33 -0
- data/app/services/uffizzi_core/manage_activity_items_service.rb +166 -0
- data/app/services/uffizzi_core/project_service.rb +38 -0
- data/app/services/uffizzi_core/repo_service.rb +178 -0
- data/app/services/uffizzi_core/response_service.rb +13 -0
- data/app/services/uffizzi_core/template_service.rb +21 -0
- data/app/services/uffizzi_core/token_service.rb +19 -0
- data/app/services/uffizzi_core/user_access_service.rb +14 -0
- data/app/utils/uffizzi_core/converters.rb +33 -0
- data/app/validators/uffizzi_core/email_validator.rb +9 -0
- data/app/validators/uffizzi_core/environment_variable_list_validator.rb +15 -0
- data/app/validators/uffizzi_core/image_command_args_validator.rb +21 -0
- data/config/initializers/rswag_api.rb +15 -0
- data/config/initializers/rswag_ui.rb +15 -0
- data/config/initializers/swagger_yard.rb +17 -0
- data/config/locales/en.activerecord.yml +18 -0
- data/config/locales/en.yml +61 -0
- data/config/routes.rb +55 -0
- data/db/migrate/20220218121438_create_uffizzi_core_tables.rb +375 -0
- data/db/migrate/20220325113342_add_name_to_uffizzi_containers.rb +7 -0
- data/db/seeds.rb +16 -0
- data/lib/tasks/uffizzi_core_tasks.rake +14 -0
- data/lib/uffizzi_core/engine.rb +15 -0
- data/lib/uffizzi_core/version.rb +5 -0
- data/lib/uffizzi_core.rb +60 -0
- data/swagger/v1/swagger.json +1278 -0
- metadata +935 -0
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module UffizziCore::MassAssignmentControlConcern
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
class_methods do
|
7
|
+
def permit(*args)
|
8
|
+
@_args = args
|
9
|
+
end
|
10
|
+
|
11
|
+
def _args
|
12
|
+
@_args
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def assign_attributes(attrs = ActionController::Parameters.new)
|
17
|
+
attrs = ActionController::Parameters.new if attrs.nil?
|
18
|
+
|
19
|
+
new_attrs = attrs.permit(*self.class._args)
|
20
|
+
super(new_attrs)
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class UffizziCore::Account::CreateCredentialJob < UffizziCore::ApplicationJob
|
4
|
+
sidekiq_options queue: :accounts, retry: 5
|
5
|
+
|
6
|
+
def perform(id)
|
7
|
+
credential = UffizziCore::Credential.find(id)
|
8
|
+
UffizziCore::AccountService.create_credential(credential)
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class UffizziCore::ActivityItem::Docker::UpdateDigestJob < UffizziCore::ApplicationJob
|
4
|
+
sidekiq_options queue: :deployments, retry: 5
|
5
|
+
|
6
|
+
def perform(id)
|
7
|
+
activity_item = UffizziCore::ActivityItem.find(id)
|
8
|
+
|
9
|
+
UffizziCore::ActivityItemService.update_docker_digest!(activity_item)
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class UffizziCore::ConfigFile::ApplyJob < UffizziCore::ApplicationJob
|
4
|
+
sidekiq_options queue: :config_files, retry: Settings.controller.resource_create_retry_count
|
5
|
+
|
6
|
+
sidekiq_retry_in do |count, exception|
|
7
|
+
case exception
|
8
|
+
when UffizziCore::ControllerService::DeploymentNotFoundError
|
9
|
+
Rails.logger.info("DEPLOYMENT_PROCESS ApplyJob retry deployment_id=#{exception.deployment_id} count=#{count}")
|
10
|
+
Settings.controller.resource_create_retry_time
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def perform(deployment_id, config_file_id)
|
15
|
+
Rails.logger.info("DEPLOYMENT_PROCESS deployment_id=#{deployment_id} Apply ConfigFile(config_file_id:#{config_file_id})")
|
16
|
+
|
17
|
+
deployment = UffizziCore::Deployment.find(deployment_id)
|
18
|
+
config_file = UffizziCore::ConfigFile.find(config_file_id)
|
19
|
+
if deployment.disabled?
|
20
|
+
Rails.logger.info("DEPLOYMENT_PROCESS deployment_id=#{deployment.id} deployment was disabled stop config file applying")
|
21
|
+
return
|
22
|
+
end
|
23
|
+
|
24
|
+
unless UffizziCore::ControllerService.deployment_exists?(deployment)
|
25
|
+
raise UffizziCore::ControllerService::DeploymentNotFoundError,
|
26
|
+
deployment_id
|
27
|
+
end
|
28
|
+
|
29
|
+
UffizziCore::ControllerService.apply_config_file(deployment, config_file)
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class UffizziCore::Credential::DockerHub::CreateWebhookJob < UffizziCore::ApplicationJob
|
4
|
+
sidekiq_options queue: :accounts, retry: 5
|
5
|
+
|
6
|
+
def perform(credential_id, image, deployment_id = nil)
|
7
|
+
if deployment_id.present?
|
8
|
+
Rails.logger.info("DEPLOYMENT_PROCESS deployment_id=#{deployment_id} DockerHub CreateWebhooksJob")
|
9
|
+
end
|
10
|
+
|
11
|
+
credential = UffizziCore::Credential.find(credential_id)
|
12
|
+
|
13
|
+
UffizziCore::DockerHubService.create_webhook(credential, image)
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class UffizziCore::Deployment::CreateCredentialJob < UffizziCore::ApplicationJob
|
4
|
+
sidekiq_options queue: :deployments, retry: Settings.controller.resource_create_retry_count
|
5
|
+
|
6
|
+
sidekiq_retry_in do |count, exception|
|
7
|
+
case exception
|
8
|
+
when UffizziCore::DeploymentNotFoundError
|
9
|
+
Rails.logger.info("DEPLOYMENT_PROCESS CreateCredentialJob retry deployment_id=#{exception.deployment_id} count=#{count}")
|
10
|
+
Settings.controller.resource_create_retry_time
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def perform(deployment_id, credential_id)
|
15
|
+
Rails.logger.info("DEPLOYMENT_PROCESS deployment_id=#{deployment_id} CreateCredentialJob(cred_id:#{credential_id})")
|
16
|
+
|
17
|
+
deployment = UffizziCore::Deployment.find(deployment_id)
|
18
|
+
credential = UffizziCore::Credential.find(credential_id)
|
19
|
+
|
20
|
+
if deployment.disabled?
|
21
|
+
Rails.logger.info("DEPLOYMENT_PROCESS deployment_id=#{deployment.id} deployment was disabled stop creating credential")
|
22
|
+
return
|
23
|
+
end
|
24
|
+
|
25
|
+
unless UffizziCore::ControllerService.deployment_exists?(deployment)
|
26
|
+
raise UffizziCore::DeploymentNotFoundError,
|
27
|
+
deployment_id
|
28
|
+
end
|
29
|
+
|
30
|
+
UffizziCore::ControllerService.apply_credential(deployment, credential)
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class UffizziCore::Deployment::CreateCredentialsJob < UffizziCore::ApplicationJob
|
4
|
+
sidekiq_options queue: :deployments, retry: 5
|
5
|
+
|
6
|
+
def perform(deployment_id)
|
7
|
+
Rails.logger.info("DEPLOYMENT_PROCESS deployment_id=#{deployment_id} CreateCredentialsJob")
|
8
|
+
|
9
|
+
deployment = UffizziCore::Deployment.find(deployment_id)
|
10
|
+
|
11
|
+
credentials = deployment.project.account.credentials.deployable
|
12
|
+
|
13
|
+
credentials.each do |credential|
|
14
|
+
UffizziCore::Deployment::CreateCredentialJob.perform_async(deployment.id, credential.id)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class UffizziCore::Deployment::CreateJob < UffizziCore::ApplicationJob
|
4
|
+
sidekiq_options queue: :deployments, retry: 5
|
5
|
+
|
6
|
+
def perform(id)
|
7
|
+
Rails.logger.info("DEPLOYMENT_PROCESS deployment_id=#{id} CreateJob")
|
8
|
+
|
9
|
+
deployment = UffizziCore::Deployment.find(id)
|
10
|
+
|
11
|
+
UffizziCore::ControllerService.create_deployment(deployment)
|
12
|
+
|
13
|
+
UffizziCore::Deployment::CreateCredentialsJob.perform_async(deployment.id)
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class UffizziCore::Deployment::CreateWebhooksJob < UffizziCore::ApplicationJob
|
4
|
+
sidekiq_options queue: :deployments, retry: 5
|
5
|
+
|
6
|
+
def perform(id)
|
7
|
+
Rails.logger.info("DEPLOYMENT_PROCESS deployment_id=#{id} CreateWebhooksJob")
|
8
|
+
|
9
|
+
deployment = UffizziCore::Deployment.find(id)
|
10
|
+
|
11
|
+
UffizziCore::DeploymentService.create_webhooks(deployment)
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class UffizziCore::Deployment::DeleteCredentialJob < UffizziCore::ApplicationJob
|
4
|
+
sidekiq_options queue: :deployments, retry: 5
|
5
|
+
|
6
|
+
def perform(deployment_id, credential_id)
|
7
|
+
Rails.logger.info("DEPLOYMENT_PROCESS deployment_id=#{deployment_id} DeleteCredentialJob(cred_id:#{credential_id})")
|
8
|
+
|
9
|
+
deployment = UffizziCore::Deployment.find(deployment_id)
|
10
|
+
credential = UffizziCore::Credential.find(credential_id)
|
11
|
+
UffizziCore::ControllerService.delete_credential(deployment, credential)
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class UffizziCore::Deployment::DeleteJob < UffizziCore::ApplicationJob
|
4
|
+
sidekiq_options queue: :deployments, retry: 5
|
5
|
+
|
6
|
+
def perform(id)
|
7
|
+
Rails.logger.info("DEPLOYMENT_PROCESS deployment_id=#{id} DeleteJob")
|
8
|
+
|
9
|
+
UffizziCore::ControllerService.delete_deployment(id)
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class UffizziCore::Deployment::DeployContainersJob < UffizziCore::ApplicationJob
|
4
|
+
sidekiq_options queue: :deployments, retry: Settings.controller.resource_create_retry_count
|
5
|
+
|
6
|
+
sidekiq_retry_in do |count, exception|
|
7
|
+
case exception
|
8
|
+
when UffizziCore::DeploymentNotFoundError
|
9
|
+
Rails.logger.info("DEPLOYMENT_PROCESS DeployContainersJob retry deployment_id=#{exception.deployment_id} count=#{count}")
|
10
|
+
Settings.controller.resource_create_retry_time
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def perform(id, repeated = false)
|
15
|
+
Rails.logger.info("DEPLOYMENT_PROCESS deployment_id=#{id} DeployContainersJob")
|
16
|
+
|
17
|
+
deployment = UffizziCore::Deployment.find(id)
|
18
|
+
if deployment.disabled?
|
19
|
+
Rails.logger.info("DEPLOYMENT_PROCESS deployment_id=#{deployment.id} deployment was disabled stop deploying")
|
20
|
+
return
|
21
|
+
end
|
22
|
+
|
23
|
+
raise UffizziCore::DeploymentNotFoundError, id unless UffizziCore::ControllerService.deployment_exists?(deployment)
|
24
|
+
|
25
|
+
UffizziCore::DeploymentService.deploy_containers(deployment, repeated)
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class UffizziCore::Deployment::ManageDeployActivityItemJob < UffizziCore::ApplicationJob
|
4
|
+
sidekiq_options queue: :deployments, retry: 5
|
5
|
+
|
6
|
+
def perform(id)
|
7
|
+
activity_item = UffizziCore::ActivityItem.find(id)
|
8
|
+
container = activity_item.container
|
9
|
+
|
10
|
+
if container.disabled?
|
11
|
+
logger_message = "DEPLOYMENT_PROCESS deployment_id=#{container.deployment_id} activity_item_id=#{activity_item.id}
|
12
|
+
deployment was disabled stop monitoring"
|
13
|
+
Rails.logger.info(logger_message)
|
14
|
+
return
|
15
|
+
end
|
16
|
+
|
17
|
+
UffizziCore::ActivityItemService.manage_deploy_activity_item(activity_item)
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class UffizziCore::Deployment::SendGithubPreviewMessageJob < UffizziCore::ApplicationJob
|
4
|
+
sidekiq_options queue: :deployments, retry: 5
|
5
|
+
|
6
|
+
def perform(deployment_id)
|
7
|
+
Rails.logger.info("DEPLOYMENT_PROCESS deployment_id=#{deployment_id} SendGithubPreviewMessageJob")
|
8
|
+
|
9
|
+
deployment = UffizziCore::Deployment.find(deployment_id)
|
10
|
+
|
11
|
+
UffizziCore::GithubService.send_preview_message(deployment)
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module UffizziCore::Rbac::UserAccessService
|
4
|
+
class << self
|
5
|
+
def admin_access_to_account?(_user, _account)
|
6
|
+
true
|
7
|
+
end
|
8
|
+
|
9
|
+
def any_access_to_account?(_user, _account)
|
10
|
+
true
|
11
|
+
end
|
12
|
+
|
13
|
+
def admin_or_developer_access_to_project?(_user, _project)
|
14
|
+
true
|
15
|
+
end
|
16
|
+
|
17
|
+
def any_access_to_project?(_user, _project)
|
18
|
+
true
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module UffizziCore::HashidConcern
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
class_methods do
|
7
|
+
def hashid_service
|
8
|
+
@hashid_service ||= Hashids.new("#{Rails.application.secrets.secret_key_base}-#{name}")
|
9
|
+
end
|
10
|
+
|
11
|
+
def find_by_hashid(hashid)
|
12
|
+
id = hashid_service.decode(hashid.to_s).first
|
13
|
+
find_by(id: id)
|
14
|
+
end
|
15
|
+
|
16
|
+
def find_by_hashid!(hashid)
|
17
|
+
id = hashid_service.decode(hashid.to_s).first
|
18
|
+
find(id)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def hashid
|
23
|
+
self.class.hashid_service.encode(id)
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module UffizziCore::StateMachineConcern
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
class_methods do
|
7
|
+
def aasm(attribute, *args)
|
8
|
+
attr_accessor(:"#{attribute}_event")
|
9
|
+
|
10
|
+
define_method("#{attribute}_event=") do |value|
|
11
|
+
send(value)
|
12
|
+
end
|
13
|
+
super(attribute, *args)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class UffizziCore::Account < UffizziCore::ApplicationRecord
|
4
|
+
include AASM
|
5
|
+
include UffizziCore::StateMachineConcern
|
6
|
+
extend Enumerize
|
7
|
+
|
8
|
+
self.table_name = UffizziCore.table_names[:accounts]
|
9
|
+
|
10
|
+
enumerize :kind, in: [:personal, :organizational], scope: true, predicates: true
|
11
|
+
validates :kind, presence: true
|
12
|
+
validates :domain, uniqueness: true, if: :domain
|
13
|
+
|
14
|
+
belongs_to :owner, class_name: UffizziCore::User.name, foreign_key: :owner_id
|
15
|
+
|
16
|
+
has_many :memberships, dependent: :destroy
|
17
|
+
has_many :users, through: :memberships
|
18
|
+
has_many :credentials, dependent: :destroy
|
19
|
+
|
20
|
+
has_many :projects, dependent: :destroy
|
21
|
+
has_many :deployments, through: :projects
|
22
|
+
has_many :payments, dependent: :destroy
|
23
|
+
has_many :invitations, as: :entityable
|
24
|
+
|
25
|
+
aasm(:state) do
|
26
|
+
state :active, initial: true
|
27
|
+
state :payment_issue
|
28
|
+
state :disabled
|
29
|
+
state :draft
|
30
|
+
|
31
|
+
# next states should be removed after migration
|
32
|
+
state :trial
|
33
|
+
state :trial_expired
|
34
|
+
state :past_due
|
35
|
+
|
36
|
+
event :activate do
|
37
|
+
transitions from: [:payment_issue, :disabled, :trial, :trial_expired, :past_due, :draft], to: :active
|
38
|
+
end
|
39
|
+
|
40
|
+
event :raise_payment_issue, before_success: :update_payment_issue_date do
|
41
|
+
transitions from: [:active, :trial, :trial_expired, :past_due, :disabled], to: :payment_issue
|
42
|
+
end
|
43
|
+
|
44
|
+
event :disable, after: :disable_projects do
|
45
|
+
transitions from: [:active, :trial, :trial_expired, :past_due, :payment_issue], to: :disabled
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
aasm(:sso_state) do
|
50
|
+
state :connection_not_configured, initial: true
|
51
|
+
state :connection_disabled
|
52
|
+
state :connection_active
|
53
|
+
|
54
|
+
event :activate_connection do
|
55
|
+
transitions from: [:connection_not_configured, :connection_disabled], to: :connection_active
|
56
|
+
end
|
57
|
+
|
58
|
+
event :deactivate_connection do
|
59
|
+
transitions from: [:connection_active], to: :connection_disabled
|
60
|
+
end
|
61
|
+
|
62
|
+
event :reset_connection do
|
63
|
+
transitions from: [:connection_active, :connection_disabled], to: :connection_not_configured
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def update_payment_issue_date
|
68
|
+
update(payment_issue_at: DateTime.current)
|
69
|
+
end
|
70
|
+
|
71
|
+
def can_create_new_resources?
|
72
|
+
return active? if Settings.features.stripe_enabled
|
73
|
+
|
74
|
+
true
|
75
|
+
end
|
76
|
+
|
77
|
+
def active_projects
|
78
|
+
projects.active
|
79
|
+
end
|
80
|
+
|
81
|
+
def disable_paid_deployments
|
82
|
+
deployments.active.where('kind != ?', UffizziCore::Deployment.kind.free).each(&:disable!)
|
83
|
+
end
|
84
|
+
|
85
|
+
def disable_projects
|
86
|
+
active_projects.each(&:disable_deployments)
|
87
|
+
end
|
88
|
+
|
89
|
+
def any_paid_projects?
|
90
|
+
projects.any?(&:any_paid_deployments?)
|
91
|
+
end
|
92
|
+
|
93
|
+
def cards
|
94
|
+
StripeService.cards(self)
|
95
|
+
end
|
96
|
+
|
97
|
+
# This method is deprecated. Don't use it.
|
98
|
+
def user
|
99
|
+
users.find_by(memberships: { role: UffizziCore::Membership.role.admin })
|
100
|
+
end
|
101
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# @model
|
4
|
+
#
|
5
|
+
# @property id [integer]
|
6
|
+
# @property namespace [string]
|
7
|
+
# @property name(required) [string]
|
8
|
+
# @property tag [string]
|
9
|
+
# @property branch [string]
|
10
|
+
# @property type [string]
|
11
|
+
# @property container_id [string]
|
12
|
+
# @property commit [string]
|
13
|
+
# @property commit_message [string]
|
14
|
+
# @property build_id [integer]
|
15
|
+
# @property created_at [date]
|
16
|
+
# @property updated_at [date]
|
17
|
+
# @property data [object]
|
18
|
+
# @property digest [string]
|
19
|
+
# @property meta [object]
|
20
|
+
|
21
|
+
class UffizziCore::ActivityItem < UffizziCore::ApplicationRecord
|
22
|
+
include UffizziCore::ActivityItemRepo
|
23
|
+
|
24
|
+
self.table_name = UffizziCore.table_names[:activity_items]
|
25
|
+
|
26
|
+
belongs_to :deployment
|
27
|
+
belongs_to :container
|
28
|
+
belongs_to :build, optional: true
|
29
|
+
|
30
|
+
has_many :events, dependent: :destroy
|
31
|
+
|
32
|
+
scope :docker, -> {
|
33
|
+
where(type: UffizziCore::ActivityItem::Docker.name)
|
34
|
+
}
|
35
|
+
|
36
|
+
scope :github, -> {
|
37
|
+
where(type: UffizziCore::ActivityItem::Github.name)
|
38
|
+
}
|
39
|
+
|
40
|
+
def github?
|
41
|
+
type == UffizziCore::ActivityItem::Github.name
|
42
|
+
end
|
43
|
+
|
44
|
+
def docker?
|
45
|
+
type == UffizziCore::ActivityItem::Docker.name
|
46
|
+
end
|
47
|
+
|
48
|
+
def image
|
49
|
+
[namespace, name].compact.join('/')
|
50
|
+
end
|
51
|
+
|
52
|
+
def full_image
|
53
|
+
return "#{image}:#{branch}" if github?
|
54
|
+
return "#{image}:#{tag}" if docker?
|
55
|
+
|
56
|
+
''
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class UffizziCore::Build < UffizziCore::ApplicationRecord
|
4
|
+
include UffizziCore::BuildRepo
|
5
|
+
|
6
|
+
self.table_name = UffizziCore.table_names[:builds]
|
7
|
+
|
8
|
+
BUILDING = 1
|
9
|
+
SUCCESS = 2
|
10
|
+
FAILED = 3
|
11
|
+
TIMEOUT = 4
|
12
|
+
CANCELLED = 5
|
13
|
+
|
14
|
+
belongs_to :repo
|
15
|
+
|
16
|
+
def successful?
|
17
|
+
status == SUCCESS
|
18
|
+
end
|
19
|
+
|
20
|
+
def unsuccessful?
|
21
|
+
[FAILED, TIMEOUT, CANCELLED].include?(status)
|
22
|
+
end
|
23
|
+
|
24
|
+
def failed?
|
25
|
+
status == FAILED
|
26
|
+
end
|
27
|
+
|
28
|
+
def building?
|
29
|
+
status == BUILDING
|
30
|
+
end
|
31
|
+
|
32
|
+
def timed_out?
|
33
|
+
status == TIMEOUT
|
34
|
+
end
|
35
|
+
|
36
|
+
def cancelled?
|
37
|
+
status == CANCELLED
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class UffizziCore::Comment < UffizziCore::ApplicationRecord
|
4
|
+
include UffizziCore::CommentRepo
|
5
|
+
|
6
|
+
self.table_name = UffizziCore.table_names[:comments]
|
7
|
+
|
8
|
+
has_ancestry(cache_depth: true)
|
9
|
+
MAX_DEPTH_LEVEL = 1
|
10
|
+
|
11
|
+
belongs_to :user
|
12
|
+
belongs_to :commentable, polymorphic: true
|
13
|
+
|
14
|
+
validates :content, length: { maximum: 1500 }, presence: true
|
15
|
+
validates :ancestry_depth, numericality: { less_than_or_equal_to: MAX_DEPTH_LEVEL, only_integer: true }
|
16
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# @model ComposeFile
|
4
|
+
# @property id [integer]
|
5
|
+
# @property source [string]
|
6
|
+
# @property path [string]
|
7
|
+
# @property content(required) [string]
|
8
|
+
# @property auto_deploy [boolean]
|
9
|
+
# @property state [string]
|
10
|
+
# @property payload [string]
|
11
|
+
|
12
|
+
class UffizziCore::ComposeFile < UffizziCore::ApplicationRecord
|
13
|
+
include UffizziCore::ComposeFileRepo
|
14
|
+
include AASM
|
15
|
+
extend Enumerize
|
16
|
+
|
17
|
+
self.table_name = UffizziCore.table_names[:compose_files]
|
18
|
+
|
19
|
+
belongs_to :project
|
20
|
+
belongs_to :added_by, class_name: UffizziCore::User.name, foreign_key: :added_by_id, optional: true
|
21
|
+
|
22
|
+
has_one :template, dependent: :destroy
|
23
|
+
has_many :config_files, dependent: :destroy
|
24
|
+
has_many :deployments, dependent: :nullify
|
25
|
+
|
26
|
+
enumerize :kind, in: [:main, :temporary], predicates: true, scope: :shallow, default: :main
|
27
|
+
|
28
|
+
validates :project, uniqueness: { scope: :project }, if: -> { kind.main? }
|
29
|
+
validates :source, presence: true
|
30
|
+
validates :source, uniqueness: { scope: :project }, if: -> { kind.main? }
|
31
|
+
|
32
|
+
aasm(:auto_deploy) do
|
33
|
+
state :disabled, initial: true
|
34
|
+
state :enabled
|
35
|
+
|
36
|
+
event :enable do
|
37
|
+
transitions from: [:disabled], to: :enabled
|
38
|
+
end
|
39
|
+
|
40
|
+
event :disable do
|
41
|
+
transitions from: [:enabled], to: :disabled
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
aasm(:state) do
|
46
|
+
state :valid_file, initial: true
|
47
|
+
state :invalid_file
|
48
|
+
|
49
|
+
event :set_valid do
|
50
|
+
transitions from: [:invalid_file], to: :valid_file
|
51
|
+
end
|
52
|
+
|
53
|
+
event :set_invalid do
|
54
|
+
transitions from: [:valid_file], to: :invalid_file
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|