diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 10:34:06 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 10:34:06 +0000 |
commit | 859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 (patch) | |
tree | d7f2700abe6b4ffcb2dcfc80631b2d87d0609239 /app/models/terraform | |
parent | 446d496a6d000c73a304be52587cd9bbc7493136 (diff) | |
download | gitlab-ce-859a6fb938bb9ee2a317c46dfa4fcc1af49608f0.tar.gz |
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc42
Diffstat (limited to 'app/models/terraform')
-rw-r--r-- | app/models/terraform/state.rb | 2 | ||||
-rw-r--r-- | app/models/terraform/state_version.rb | 6 |
2 files changed, 4 insertions, 4 deletions
diff --git a/app/models/terraform/state.rb b/app/models/terraform/state.rb index efbbd86ae4a..eb7d465d585 100644 --- a/app/models/terraform/state.rb +++ b/app/models/terraform/state.rb @@ -22,7 +22,9 @@ module Terraform scope :versioning_not_enabled, -> { where(versioning_enabled: false) } 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 :uuid, presence: true, uniqueness: true, length: { is: UUID_LENGTH }, format: { with: HEX_REGEXP, message: 'only allows hex characters' } diff --git a/app/models/terraform/state_version.rb b/app/models/terraform/state_version.rb index 19d708616fc..432ac5b6422 100644 --- a/app/models/terraform/state_version.rb +++ b/app/models/terraform/state_version.rb @@ -9,16 +9,14 @@ module Terraform belongs_to :build, class_name: 'Ci::Build', optional: true, foreign_key: :ci_build_id scope :ordered_by_version_desc, -> { order(version: :desc) } + scope :with_files_stored_locally, -> { where(file_store: Terraform::StateUploader::Store::LOCAL) } + scope :preload_state, -> { includes(:terraform_state) } default_value_for(:file_store) { StateUploader.default_store } mount_file_store_uploader StateUploader delegate :project_id, :uuid, to: :terraform_state, allow_nil: true - - def local? - file_store == ObjectStorage::Store::LOCAL - end end end |