Class: Kitsune::Kit::Workflows::SupportBundle

Inherits:
Object
  • Object
show all
Defined in:
lib/kitsune/kit/workflows/support_bundle.rb

Constant Summary collapse

MAX_LOG_FILES =
5
MAX_LOG_LINES =
500

Instance Method Summary collapse

Constructor Details

#initialize(root:, config:, state_store:, doctor:, secret_filter: SecretFilter.new, clock: -> { Time.now.utc }) ⇒ SupportBundle

Returns a new instance of SupportBundle.



17
18
19
20
21
22
23
24
25
# File 'lib/kitsune/kit/workflows/support_bundle.rb', line 17

def initialize(root:, config:, state_store:, doctor:, secret_filter: SecretFilter.new,
               clock: -> { Time.now.utc })
  @root = Pathname(root).expand_path
  @config = config
  @state_store = state_store
  @doctor = doctor
  @secret_filter = secret_filter
  @clock = clock
end

Instance Method Details

#callObject



27
28
29
30
31
32
33
34
# File 'lib/kitsune/kit/workflows/support_bundle.rb', line 27

def call
  directory = root.join(".kitsune/support")
  FileUtils.mkdir_p(directory, mode: 0o700)
  path = directory.join("#{clock.call.strftime('%Y%m%dT%H%M%S')}-#{SecureRandom.hex(4)}.json")
  path.write(JSON.pretty_generate(secret_filter.filter(payload)) << "\n")
  File.chmod(0o600, path)
  path.to_s
end