2020-11-24 15:15:51 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Terraform
|
|
|
|
class VersionedStateUploader < StateUploader
|
2021-01-03 14:25:43 +05:30
|
|
|
delegate :terraform_state, to: :model
|
|
|
|
|
2020-11-24 15:15:51 +05:30
|
|
|
def filename
|
2021-01-03 14:25:43 +05:30
|
|
|
if terraform_state.versioning_enabled?
|
|
|
|
"#{model.version}.tfstate"
|
|
|
|
else
|
|
|
|
"#{model.uuid}.tfstate"
|
|
|
|
end
|
2020-11-24 15:15:51 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def store_dir
|
2021-01-03 14:25:43 +05:30
|
|
|
if terraform_state.versioning_enabled?
|
|
|
|
Gitlab::HashedPath.new(model.uuid, root_hash: project_id)
|
|
|
|
else
|
|
|
|
project_id.to_s
|
|
|
|
end
|
2020-11-24 15:15:51 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|