diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-23 15:09:11 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-23 15:09:11 +0300 |
commit | 15ea3fec22d1efd1945d390b21ff65461290dfc1 (patch) | |
tree | f5703fc0c0c4ab49eef0cc5449fb08f570b7a16b /app/models/terraform | |
parent | 8132e39e1b5a7829b8b7ed8bd0482e1812a9eeef (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/terraform')
-rw-r--r-- | app/models/terraform/state.rb | 22 | ||||
-rw-r--r-- | app/models/terraform/state_version.rb | 4 |
2 files changed, 8 insertions, 18 deletions
diff --git a/app/models/terraform/state.rb b/app/models/terraform/state.rb index e6f295ee97a..19700587f09 100644 --- a/app/models/terraform/state.rb +++ b/app/models/terraform/state.rb @@ -3,7 +3,6 @@ module Terraform class State < ApplicationRecord include UsageStatistics - include FileStoreMounter include IgnorableColumns # These columns are being removed since geo replication falls to the versioned state # Tracking in https://gitlab.com/gitlab-org/gitlab/-/issues/258262 @@ -36,18 +35,8 @@ module Terraform default_value_for(:uuid, allows_nil: false) { SecureRandom.hex(UUID_LENGTH / 2) } - mount_file_store_uploader StateUploader - - def file_store - super || StateUploader.default_store - end - def latest_file - if versioning_enabled? - latest_version&.file - else - latest_version&.file || file - end + latest_version&.file end def locked? @@ -55,13 +44,14 @@ module Terraform end def update_file!(data, version:, build:) + # This check is required to maintain backwards compatibility with + # states that were created prior to versioning being supported. + # This can be removed in 14.0 when support for these states is dropped. + # See https://gitlab.com/gitlab-org/gitlab/-/issues/258960 if versioning_enabled? create_new_version!(data: data, version: version, build: build) - elsif latest_version.present? - migrate_legacy_version!(data: data, version: version, build: build) else - self.file = data - save! + migrate_legacy_version!(data: data, version: version, build: build) end end diff --git a/app/models/terraform/state_version.rb b/app/models/terraform/state_version.rb index cc5d94b8e09..19d708616fc 100644 --- a/app/models/terraform/state_version.rb +++ b/app/models/terraform/state_version.rb @@ -10,9 +10,9 @@ module Terraform scope :ordered_by_version_desc, -> { order(version: :desc) } - default_value_for(:file_store) { VersionedStateUploader.default_store } + default_value_for(:file_store) { StateUploader.default_store } - mount_file_store_uploader VersionedStateUploader + mount_file_store_uploader StateUploader delegate :project_id, :uuid, to: :terraform_state, allow_nil: true |