diff options
Diffstat (limited to 'app/models/terraform')
-rw-r--r-- | app/models/terraform/state.rb | 12 | ||||
-rw-r--r-- | app/models/terraform/state_version.rb | 1 |
2 files changed, 2 insertions, 11 deletions
diff --git a/app/models/terraform/state.rb b/app/models/terraform/state.rb index 8c3b85ac4c3..4d17a4d332c 100644 --- a/app/models/terraform/state.rb +++ b/app/models/terraform/state.rb @@ -23,13 +23,10 @@ module Terraform scope :ordered_by_name, -> { order(:name) } scope :with_name, -> (name) { where(name: name) } - validates :name, presence: true, uniqueness: { scope: :project_id } - validates :project_id, presence: true + validates :project_id, :name, presence: true validates :uuid, presence: true, uniqueness: true, length: { is: UUID_LENGTH }, format: { with: HEX_REGEXP, message: 'only allows hex characters' } - before_destroy :ensure_state_is_unlocked - default_value_for(:uuid, allows_nil: false) { SecureRandom.hex(UUID_LENGTH / 2) } def latest_file @@ -90,13 +87,6 @@ module Terraform new_version.save! end - def ensure_state_is_unlocked - return unless locked? - - errors.add(:base, s_("Terraform|You cannot remove the State file because it's locked. Unlock the State file first before removing it.")) - throw :abort # rubocop:disable Cop/BanCatchThrow - end - def parse_serial(file) Gitlab::Json.parse(file)["serial"] rescue JSON::ParserError diff --git a/app/models/terraform/state_version.rb b/app/models/terraform/state_version.rb index 31ff7e4c27d..c50eaa66860 100644 --- a/app/models/terraform/state_version.rb +++ b/app/models/terraform/state_version.rb @@ -2,6 +2,7 @@ module Terraform class StateVersion < ApplicationRecord + include EachBatch include FileStoreMounter belongs_to :terraform_state, class_name: 'Terraform::State', optional: false |