Class: Terraform::StateUploader

Inherits:
GitlabUploader
  • Object
show all
Includes:
ObjectStorage::Concern
Defined in:
app/uploaders/terraform/state_uploader.rb

Constant Summary

Constants inherited from GitlabUploader

GitlabUploader::ObjectNotReadyError, GitlabUploader::PROTECTED_METHODS

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ObjectStorage::Concern

#cache!, #delete_migrated_file, #delete_tmp_file_after_storage, #exclusive_lease_key, #exists?, #file_cache_storage?, #file_storage?, #filename=, #fog_attributes, #fog_credentials, #fog_directory, #fog_public, #migrate!, #object_store, #object_store=, #persist_object_store!, #persist_object_store?, #retrieve_from_store!, #store!, #store_dirs, #store_path, #upload_paths, #use_file, #use_open_file

Methods included from Gitlab::Utils::Override

#extended, extensions, #included, #method_added, #override, #prepended, #queue_verification, verify!

Methods inherited from GitlabUploader

absolute_path, base_dir, #cache_dir, #cached_size, #exists?, #file_cache_storage?, file_storage?, #initialize, #local_url, #model_valid?, #move_to_cache, #move_to_store, #multi_read, #open, #options, options, #relative_path, #replace_file_without_saving!, root, storage_location, #url_or_file_path, version, #work_dir

Constructor Details

This class inherits a constructor from GitlabUploader

Class Method Details

.default_storeObject



55
56
57
# File 'app/uploaders/terraform/state_uploader.rb', line 55

def default_store
  object_store_enabled? ? ObjectStorage::Store::REMOTE : ObjectStorage::Store::LOCAL
end

.direct_upload_enabled?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'app/uploaders/terraform/state_uploader.rb', line 47

def direct_upload_enabled?
  false
end

.proxy_download_enabled?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'app/uploaders/terraform/state_uploader.rb', line 51

def proxy_download_enabled?
  true
end

Instance Method Details

#filenameObject



18
19
20
21
22
23
24
25
26
27
28
# File 'app/uploaders/terraform/state_uploader.rb', line 18

def filename
  # 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 terraform_state.versioning_enabled?
    "#{model.version}.tfstate"
  else
    "#{model.uuid}.tfstate"
  end
end

#keyObject



42
43
44
# File 'app/uploaders/terraform/state_uploader.rb', line 42

def key
  OpenSSL::HMAC.digest('SHA256', Gitlab::Application.secrets.db_key_base, project_id.to_s)
end

#store_dirObject



30
31
32
33
34
35
36
37
38
39
40
# File 'app/uploaders/terraform/state_uploader.rb', line 30

def store_dir
  # 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 terraform_state.versioning_enabled?
    Gitlab::HashedPath.new(model.uuid, root_hash: project_id)
  else
    project_id.to_s
  end
end