Class: UffizziCore::Api::Cli::V1::Projects::DeploymentsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- UffizziCore::Api::Cli::V1::Projects::DeploymentsController
- Includes:
- DeploymentsControllerModule
- Defined in:
- app/controllers/uffizzi_core/api/cli/v1/projects/deployments_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
Create a deployment from a compose file.
- #deploy_containers ⇒ Object
-
#destroy ⇒ Object
Disable deployment by id.
-
#index ⇒ Object
Get a list of active deployements for a project.
-
#show ⇒ Object
Get deployment information by id.
-
#update ⇒ Object
Update the deployment with new compose file.
Instance Method Details
#create ⇒ Object
Create a deployment from a compose file
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'app/controllers/uffizzi_core/api/cli/v1/projects/deployments_controller.rb', line 54 def create return render_deployment_exists_error if deployments..with_labels().exists? compose_file, errors = find_or_create_compose_file return render_invalid_file if compose_file.invalid_file? return render_errors(errors) if errors.present? errors = check_credentials(compose_file) return render_errors(errors) if errors.present? params = { metadata: , creation_source: creation_source_params, } deployment = UffizziCore::DeploymentService.create_from_compose(compose_file, resource_project, current_user, params) respond_with deployment end |
#deploy_containers ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 |
# File 'app/controllers/uffizzi_core/api/cli/v1/projects/deployments_controller.rb', line 115 def deploy_containers deployment = resource_project.deployments.active.find(params[:id]) deployment.update(deployed_by: current_user) resource_project.config_files.by_deployment(deployment).each do |config_file| UffizziCore::ConfigFile::ApplyJob.perform_async(deployment.id, config_file.id) end UffizziCore::Deployment::DeployContainersJob.perform_async(deployment.id) end |
#destroy ⇒ Object
Disable deployment by id
135 136 137 138 139 140 |
# File 'app/controllers/uffizzi_core/api/cli/v1/projects/deployments_controller.rb', line 135 def destroy UffizziCore::DeploymentService.disable!(deployment) deployment.deployment_events.create!(deployment_state: deployment.state, message: 'Destroyed by CLI') head :no_content end |
#index ⇒ Object
Get a list of active deployements for a project
21 22 23 24 25 26 |
# File 'app/controllers/uffizzi_core/api/cli/v1/projects/deployments_controller.rb', line 21 def index search_labels = JSON.parse(q_param) filtered_deployments = deployments.with_labels(search_labels) respond_with filtered_deployments, each_serializer: UffizziCore::Api::Cli::V1::Projects::DeploymentsSerializer end |
#show ⇒ Object
Get deployment information by id
37 38 39 |
# File 'app/controllers/uffizzi_core/api/cli/v1/projects/deployments_controller.rb', line 37 def show respond_with deployment end |
#update ⇒ Object
Update the deployment with new compose file
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'app/controllers/uffizzi_core/api/cli/v1/projects/deployments_controller.rb', line 87 def update compose_file, errors = UffizziCore::ComposeFileService.create_temporary_compose( resource_project, current_user, compose_file_params, dependencies_params[:dependencies], ) return render_invalid_file if compose_file.invalid_file? return render_errors(errors) if errors.present? errors = check_credentials(compose_file) return render_errors(errors) if errors.present? deployment = deployments.find(params[:id]) updated_deployment = UffizziCore::DeploymentService.update_from_compose(compose_file, resource_project, current_user, deployment, ) respond_with updated_deployment end |