aboutsummaryrefslogtreecommitdiff
path: root/app/models/backends/terraform_libvirt.rb
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2018-04-05 22:58:56 +0100
committerChristopher Baines <mail@cbaines.net>2018-04-12 08:30:05 +0100
commitb03a664ec42bd93a7547fb53216ab3ae5d099dcd (patch)
treef15bbc4e10ab4f6df3e51c194d5aea2f488215bf /app/models/backends/terraform_libvirt.rb
parent4238b1f3bc88ab2a1d97aa3c4967361c853b4880 (diff)
downloadgovuk-mini-environment-admin-b03a664ec42bd93a7547fb53216ab3ae5d099dcd.tar
govuk-mini-environment-admin-b03a664ec42bd93a7547fb53216ab3ae5d099dcd.tar.gz
Move the terraform utilities to lib/
Change the module to a class, which is used to represent a terraform working directory. Change the routing for the terraform http backends, to remove any connection with mini environments, and remove this concern from the new TerraformWorkingDirectory class also.
Diffstat (limited to 'app/models/backends/terraform_libvirt.rb')
-rw-r--r--app/models/backends/terraform_libvirt.rb13
1 files changed, 9 insertions, 4 deletions
diff --git a/app/models/backends/terraform_libvirt.rb b/app/models/backends/terraform_libvirt.rb
index 147c27d..f108560 100644
--- a/app/models/backends/terraform_libvirt.rb
+++ b/app/models/backends/terraform_libvirt.rb
@@ -33,8 +33,6 @@
require 'ruby_terraform'
class Backends::TerraformLibvirt < ApplicationRecord
- include Backends::Terraform
-
has_many :mini_environments, as: :backend
self.table_name = 'terraform_libvirt_backends'
@@ -65,7 +63,7 @@ class Backends::TerraformLibvirt < ApplicationRecord
def start(mini_environment)
logger.info "Setting up #{mini_environment.name}"
- with_terraform(mini_environment, 'terraform/libvirt') do
+ within_terraform_working_directory(mini_environment) do
RubyTerraform.apply(
vars: terraform_variables(mini_environment),
auto_approve: true
@@ -74,7 +72,7 @@ class Backends::TerraformLibvirt < ApplicationRecord
end
def destroy(mini_environment)
- with_terraform(mini_environment, 'terraform/libvirt') do
+ within_terraform_working_directory(mini_environment) do
RubyTerraform.destroy(
vars: terraform_variables(mini_environment),
force: true
@@ -82,6 +80,13 @@ class Backends::TerraformLibvirt < ApplicationRecord
end
end
+ def within_terraform_working_directory(mini_environment, &block)
+ TerraformWorkingDirectory.new(
+ "mini_environment/#{mini_environment.id}",
+ 'terraform/libvirt'
+ ).within_working_directory(&block)
+ end
+
def signon_url(mini_environment)
"https://signon.#{mini_environment.name.parameterize}.#{domain}"
end