summaryrefslogtreecommitdiff
path: root/lib/api/terraform/state.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/api/terraform/state.rb')
-rw-r--r--lib/api/terraform/state.rb7
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/api/terraform/state.rb b/lib/api/terraform/state.rb
index f6e966defce..7063a3d08b5 100644
--- a/lib/api/terraform/state.rb
+++ b/lib/api/terraform/state.rb
@@ -35,10 +35,10 @@ module API
route_setting :authentication, basic_auth_personal_access_token: true, job_token_allowed: :basic_auth
get do
remote_state_handler.find_with_lock do |state|
- no_content! unless state.file.exists?
+ no_content! unless state.latest_file && state.latest_file.exists?
env['api.format'] = :binary # this bypasses json serialization
- body state.file.read
+ body state.latest_file.read
status :ok
end
end
@@ -52,8 +52,7 @@ module API
no_content! if data.empty?
remote_state_handler.handle_with_lock do |state|
- state.file = CarrierWaveStringFile.new(data)
- state.save!
+ state.update_file!(CarrierWaveStringFile.new(data), version: params[:serial])
status :ok
end
end