Class: Gitlab::Doctor::ResetTokens

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/doctor/reset_tokens.rb

Constant Summary collapse

1000

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(logger, model_names:, token_names:, dry_run: true) ⇒ ResetTokens

Returns a new instance of ResetTokens.



10
11
12
13
14
15
# File 'lib/gitlab/doctor/reset_tokens.rb', line 10

def initialize(logger, model_names:, token_names:, dry_run: true)
  @logger = logger
  @model_names = model_names
  @token_names = token_names
  @dry_run = dry_run
end

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger.



6
7
8
# File 'lib/gitlab/doctor/reset_tokens.rb', line 6

def logger
  @logger
end

Instance Method Details

#run!Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/gitlab/doctor/reset_tokens.rb', line 17

def run!
  logger.info "Resetting #{@token_names.join(', ')} on #{@model_names.join(', ')} if they can not be read"
  logger.info "Executing in DRY RUN mode, no records will actually be updated" if @dry_run
  Rails.application.eager_load!

  models_with_encrypted_tokens.each do |model|
    fix_model(model)
  end
  logger.info "Done!"
end