From 358cdccfa8fba8d446543b7347f89098d904e136 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Thu, 5 Jul 2018 11:48:42 +0100 Subject: Only show available backends on the setup page --- app/models/backends/terraform_aws.rb | 4 ++++ app/models/backends/terraform_libvirt.rb | 4 ++++ app/views/setup/show.html.erb | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/models/backends/terraform_aws.rb b/app/models/backends/terraform_aws.rb index 65ca68c..d3d56d1 100644 --- a/app/models/backends/terraform_aws.rb +++ b/app/models/backends/terraform_aws.rb @@ -50,6 +50,10 @@ class Backends::TerraformAws < ApplicationRecord 'Amazon Web Services' end + def self.available? + File.exist? "#{ENV['PATH'].split(':').first}/terraform-provider-aws" + end + def type_and_id "#{self.class.name}=#{id}" end diff --git a/app/models/backends/terraform_libvirt.rb b/app/models/backends/terraform_libvirt.rb index b8bdf13..bbc872a 100644 --- a/app/models/backends/terraform_libvirt.rb +++ b/app/models/backends/terraform_libvirt.rb @@ -44,6 +44,10 @@ class Backends::TerraformLibvirt < ApplicationRecord 'libvirt' end + def self.available? + File.exist? "#{ENV['PATH'].split(':').first}/terraform-provider-libvirts" + end + def type_and_id "#{self.class.name}=#{id}" end diff --git a/app/views/setup/show.html.erb b/app/views/setup/show.html.erb index c3ed3b8..cc1d094 100644 --- a/app/views/setup/show.html.erb +++ b/app/views/setup/show.html.erb @@ -24,7 +24,7 @@ License along with the GOV.UK Mini Environment Admin. If not, see

Backends

-<% Backends.classes.each do |backend_class| %> +<% Backends.classes.select(&:available?).each do |backend_class| %>
-- cgit v1.2.3