Class: UffizziCore::Api::Cli::V1::Projects::DeploymentsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/uffizzi_core/api/cli/v1/projects/deployments_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

Create a deployment from a compose file



46
47
48
49
50
51
52
53
54
55
56
57
# File 'app/controllers/uffizzi_core/api/cli/v1/projects/deployments_controller.rb', line 46

def create
  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?

  deployment = UffizziCore::DeploymentService.create_from_compose(compose_file, resource_project, current_user)

  respond_with deployment
end

#deploy_containersObject



94
95
96
97
98
99
100
101
102
103
104
# File 'app/controllers/uffizzi_core/api/cli/v1/projects/deployments_controller.rb', line 94

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

#destroyObject

Disable deployment by id



114
115
116
117
118
# File 'app/controllers/uffizzi_core/api/cli/v1/projects/deployments_controller.rb', line 114

def destroy
  UffizziCore::DeploymentService.disable!(deployment)

  head :no_content
end

#indexObject

Get a list of active deployements for a project



16
17
18
# File 'app/controllers/uffizzi_core/api/cli/v1/projects/deployments_controller.rb', line 16

def index
  respond_with deployments
end

#showObject

Get deployment information by id



29
30
31
# File 'app/controllers/uffizzi_core/api/cli/v1/projects/deployments_controller.rb', line 29

def show
  respond_with deployment
end

#updateObject

Update the deployment with new compose file



72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'app/controllers/uffizzi_core/api/cli/v1/projects/deployments_controller.rb', line 72

def update
  compose_file, errors = create_temporary_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?

  deployment_id = params[:id]
  deployment = UffizziCore::DeploymentService.update_from_compose(compose_file, resource_project, current_user, deployment_id)

  respond_with deployment
end