aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/controllers/backends/terraform_aws_controller.rb8
-rw-r--r--app/controllers/backends/terraform_libvirt_controller.rb8
2 files changed, 12 insertions, 4 deletions
diff --git a/app/controllers/backends/terraform_aws_controller.rb b/app/controllers/backends/terraform_aws_controller.rb
index b09001d..3902679 100644
--- a/app/controllers/backends/terraform_aws_controller.rb
+++ b/app/controllers/backends/terraform_aws_controller.rb
@@ -49,8 +49,12 @@ class Backends::TerraformAwsController < ApplicationController
def destroy
backend = Backends::TerraformAws.find(params[:id])
- flash[:success] = "Backend #{backend.label} deleted"
- backend.delete
+ if backend.mini_environments.empty?
+ flash[:success] = "Backend #{backend.label} deleted"
+ backend.delete
+ else
+ flash[:error] = "Unable to delete backend, as mini environments using this backend still exist."
+ end
redirect_to setup_path
end
diff --git a/app/controllers/backends/terraform_libvirt_controller.rb b/app/controllers/backends/terraform_libvirt_controller.rb
index 1bf37cd..159fbb1 100644
--- a/app/controllers/backends/terraform_libvirt_controller.rb
+++ b/app/controllers/backends/terraform_libvirt_controller.rb
@@ -51,8 +51,12 @@ class Backends::TerraformLibvirtController < ApplicationController
def destroy
backend = Backends::TerraformLibvirt.find(params['id'])
- flash[:success] = "Backend #{backend.label} deleted"
- backend.delete
+ if backend.mini_environments.empty?
+ flash[:success] = "Backend #{backend.label} deleted"
+ backend.delete
+ else
+ flash[:error] = "Unable to delete backend, as mini environments using this backend still exist."
+ end
redirect_to setup_path
end