diff options
author | Christopher Baines <mail@cbaines.net> | 2018-06-23 11:16:26 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2018-06-23 12:58:05 +0100 |
commit | 05df9f91e9bdf39b190710ef5d80162d03dd52c5 (patch) | |
tree | 4a092a555a120131f8b3f096d274d2e3afc5bbae /app/controllers | |
parent | 837e1ecec9798381f78b838947f8028403cb0bef (diff) | |
download | govuk-mini-environment-admin-05df9f91e9bdf39b190710ef5d80162d03dd52c5.tar govuk-mini-environment-admin-05df9f91e9bdf39b190710ef5d80162d03dd52c5.tar.gz |
Support managing the libvirt backend from the show page
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/backends/terraform_libvirt_controller.rb | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/app/controllers/backends/terraform_libvirt_controller.rb b/app/controllers/backends/terraform_libvirt_controller.rb index bbc5e08..1feae41 100644 --- a/app/controllers/backends/terraform_libvirt_controller.rb +++ b/app/controllers/backends/terraform_libvirt_controller.rb @@ -26,7 +26,7 @@ class Backends::TerraformLibvirtController < ApplicationController def create backend = Backends::TerraformLibvirt.create(create_params) - Backends::DeployTerraformLibvirtJob.enqueue(backend.id) + Backends::TerraformLibvirtJob.enqueue(backend.id, :deploy_backend) flash[:success] = "Backend #{backend.label} created" @@ -57,6 +57,27 @@ class Backends::TerraformLibvirtController < ApplicationController redirect_to setup_path end + def perform_action + @backend = Backends::TerraformLibvirt.find(params['id']) + + action = params.require(:commit) + + case action + when 'Destroy' + Backends::TerraformLibvirtJob.enqueue(@backend.id, :destroy_backend) + + flash[:notice] = 'Destroying the backend' + when 'Deploy' + Backends::TerraformLibvirtJob.enqueue(@backend.id, :deploy_backend) + + flash[:notice] = 'Deploying the backend' + else + flash[:error] = "Unknown action #{action}" + end + + render 'show' + end + private def create_params |