Class: Import::Offline::Export

Inherits:
ApplicationRecord show all
Includes:
AfterCommitQueue
Defined in:
app/models/import/offline/export.rb

Constant Summary collapse

KNOWN_IMPORT_HOSTS =
%w[github.com bitbucket.org gitea.com].freeze
PURGE_CONFIGURATION_DELAY =
24.hours

Constants inherited from ApplicationRecord

ApplicationRecord::MAX_PLUCK

Constants included from HasCheckConstraints

HasCheckConstraints::NOT_NULL_CHECK_PATTERN

Constants included from ResetOnColumnErrors

ResetOnColumnErrors::MAX_RESET_PERIOD

Class Method Summary collapse

Instance Method Summary collapse

Methods included from AfterCommitQueue

#run_after_commit, #run_after_commit_or_now

Methods inherited from ApplicationRecord

===, cached_column_list, #create_or_load_association, current_transaction, declarative_enum, default_select_columns, delete_all_returning, #deleted_from_database?, id_in, id_not_in, iid_in, nullable_column?, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order

Methods included from Organizations::Sharding

#sharding_organization

Methods included from ResetOnColumnErrors

#reset_on_union_error, #reset_on_unknown_attribute_error

Methods included from Gitlab::SensitiveSerializableHash

#serializable_hash

Class Method Details

.all_human_statusesObject



48
49
50
# File 'app/models/import/offline/export.rb', line 48

def self.all_human_statuses
  state_machine.states.map(&:human_name)
end

Instance Method Details

#schedule_configuration_purgeObject



64
65
66
67
68
# File 'app/models/import/offline/export.rb', line 64

def schedule_configuration_purge
  return unless configuration

  ::Import::Offline::ConfigurationPurgeWorker.perform_in(PURGE_CONFIGURATION_DELAY, configuration.id)
end

#validate_source_hostnameObject



52
53
54
55
56
57
58
59
60
61
62
# File 'app/models/import/offline/export.rb', line 52

def validate_source_hostname
  uri = Gitlab::Utils.parse_url(source_hostname)

  if KNOWN_IMPORT_HOSTS.include?(uri&.domain)
    return errors.add(:source_hostname, :invalid, message: 'must not be a known import source domain')
  end

  return if uri && uri.scheme && uri.host && uri.path.blank? && uri.query.blank?

  errors.add(:source_hostname, :invalid, message: 'must contain only scheme and host')
end