aboutsummaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2018-06-23 21:13:26 +0100
committerChristopher Baines <mail@cbaines.net>2018-06-23 21:16:39 +0100
commitdd4bad071db5e7c8423df07afb375d84a0abb8f6 (patch)
tree918fbb7cc46e4b78db72d3b251c995d3f4bb6c78 /app/controllers
parente78d219f520afd8eb38b28178bbf5148f803fd19 (diff)
downloadgovuk-mini-environment-admin-dd4bad071db5e7c8423df07afb375d84a0abb8f6.tar
govuk-mini-environment-admin-dd4bad071db5e7c8423df07afb375d84a0abb8f6.tar.gz
Add a history view for terraform states
And link to this from the mini environment page.
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/terraform_http_backend_controller.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/app/controllers/terraform_http_backend_controller.rb b/app/controllers/terraform_http_backend_controller.rb
index 4d11961..4587f8a 100644
--- a/app/controllers/terraform_http_backend_controller.rb
+++ b/app/controllers/terraform_http_backend_controller.rb
@@ -46,6 +46,25 @@ class TerraformHttpBackendController < ApplicationController
end
end
+ def show_history
+ @state = TerraformState.where(
+ state_id: state_id
+ ).order(:id).last
+
+ respond_to do |format|
+ format.html do
+ render :show
+ end
+ format.json do
+ if @state.nil?
+ render json: '{}', status: 404
+ else
+ render json: @state.data, status: 200
+ end
+ end
+ end
+ end
+
def show_by_index
@state = TerraformState.where(
state_id: state_id