File: state_version.rb

package info (click to toggle)
gitlab 17.6.5-19
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 629,368 kB
  • sloc: ruby: 1,915,304; javascript: 557,307; sql: 60,639; xml: 6,509; sh: 4,567; makefile: 1,239; python: 406
file content (24 lines) | stat: -rw-r--r-- 890 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# frozen_string_literal: true

module Terraform
  class StateVersion < ApplicationRecord
    include EachBatch
    include FileStoreMounter

    belongs_to :terraform_state, class_name: 'Terraform::State', optional: false, touch: true
    belongs_to :created_by_user, class_name: 'User', optional: true
    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) }

    attribute :file_store, default: -> { StateUploader.default_store }

    mount_file_store_uploader StateUploader

    delegate :project_id, :uuid, to: :terraform_state, allow_nil: true
  end
end

Terraform::StateVersion.prepend_mod_with('Terraform::StateVersion')