aboutsummaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2018-03-27 23:04:41 +0100
committerChristopher Baines <mail@cbaines.net>2018-04-03 21:58:55 +0100
commit94f9e2a768327479c8b2da99cd57ac717cf1589a (patch)
tree819c093f8fb7c37c6017ede36db4f01854a8bcc8 /app/controllers
parentfa06e98228d8dd80a46622c9f393bb90e680d254 (diff)
downloadgovuk-mini-environment-admin-94f9e2a768327479c8b2da99cd57ac717cf1589a.tar
govuk-mini-environment-admin-94f9e2a768327479c8b2da99cd57ac717cf1589a.tar.gz
Add domains to backends, and rework build jobs
Add a domain to the libvirt and AWS Terraform backends. Along the way, improve the backend controllers and views, and rework the build jobs, simplifying them in to a single new class GovukGuix::BuildJob, which uses configuration from the respective backend.
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/backends/terraform_aws_controller.rb34
-rw-r--r--app/controllers/backends/terraform_libvirt_controller.rb47
2 files changed, 60 insertions, 21 deletions
diff --git a/app/controllers/backends/terraform_aws_controller.rb b/app/controllers/backends/terraform_aws_controller.rb
index 72c7e3a..5669eb1 100644
--- a/app/controllers/backends/terraform_aws_controller.rb
+++ b/app/controllers/backends/terraform_aws_controller.rb
@@ -4,17 +4,22 @@ class Backends::TerraformAwsController < ApplicationController
end
def create
- backend = Backends::TerraformAws.create(backend_params)
+ backend = Backends::TerraformAws.create(create_params)
- flash[:success] = "#{backend.label} created"
+ flash[:success] = "Backend #{backend.label} created"
- redirect_to setup_path
+ redirect_to terraform_aws_backend_path(backend)
end
def update
- backend = Backends::TerraformAws.update(params[:id], backend_params)
+ @backend = Backends::TerraformAws.update(
+ params[:id],
+ update_params
+ )
+
+ flash[:success] = "Backend #{@backend.label} updated"
- flash[:success] = "#{backend.label} updated"
+ render :show
end
def show
@@ -24,18 +29,33 @@ class Backends::TerraformAwsController < ApplicationController
def destroy
backend = Backends::TerraformAws.find(params[:id])
+ flash[:success] = "Backend #{backend.label} deleted"
backend.delete
+
+ redirect_to setup_path
end
private
- def backend_params
+ def create_params
params
+ .require(:backends_terraform_aws)
.permit(
:label,
+ :domain,
:aws_region,
:aws_access_key_id,
- :aws_secret_access_key,
+ :aws_secret_access_key
+ )
+ end
+
+ def update_params
+ params
+ .require(:backends_terraform_aws)
+ .permit(
+ :label,
+ :aws_access_key_id,
+ :aws_secret_access_key
)
end
end
diff --git a/app/controllers/backends/terraform_libvirt_controller.rb b/app/controllers/backends/terraform_libvirt_controller.rb
index f854bc2..6dcba17 100644
--- a/app/controllers/backends/terraform_libvirt_controller.rb
+++ b/app/controllers/backends/terraform_libvirt_controller.rb
@@ -1,30 +1,26 @@
class Backends::TerraformLibvirtController < ApplicationController
def new
@backend = Backends::TerraformLibvirt.new
- @backend.uri = "qemu:///system"
+ @backend.uri = 'qemu:///system'
end
def create
- backend = Backends::TerraformLibvirt.create(
- params
- .require(:backends_terraform_libvirt)
- .permit(:label, :uri)
- )
+ backend = Backends::TerraformLibvirt.create(create_params)
- flash[:success] = "#{backend.label} created"
+ flash[:success] = "Backend #{backend.label} created"
- redirect_to setup_path
+ redirect_to terraform_libvirt_backend_path(backend)
end
def update
- backend = Backends::TerraformLibvirt.update(
- params[:id],
- params
- .require(:backends_terraform_libvirt)
- .permit(:label, :uri)
+ @backend = Backends::TerraformLibvirt.update(
+ params['id'],
+ update_params
)
- flash[:success] = "#{backend.label} updated"
+ flash[:success] = "Backend #{@backend.label} updated"
+
+ render :show
end
def show
@@ -34,6 +30,29 @@ class Backends::TerraformLibvirtController < ApplicationController
def destroy
backend = Backends::TerraformLibvirt.find(params['id'])
+ flash[:success] = "Backend #{backend.label} deleted"
backend.delete
+
+ redirect_to setup_path
+ end
+
+ private
+
+ def create_params
+ params
+ .require(:backends_terraform_libvirt)
+ .permit(
+ :label,
+ :domain,
+ :uri
+ )
+ end
+
+ def update_params
+ params
+ .require(:backends_terraform_libvirt)
+ .permit(
+ :label
+ )
end
end