Class: AgentCliRuntime::PreparedInvocation

Inherits:
Object
  • Object
show all
Defined in:
lib/agent_cli_runtime/values.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(invocation:, environment:, credential_environment_keys:, invocation_root:, generated_paths:, configuration_path:, requested_route:, configuration_source:, probe_result:, cleanup:, executable: nil) ⇒ PreparedInvocation

Returns a new instance of PreparedInvocation.



374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
# File 'lib/agent_cli_runtime/values.rb', line 374

def initialize(invocation:, environment:, credential_environment_keys:,
               invocation_root:, generated_paths:, configuration_path:,
               requested_route:, configuration_source:, probe_result:,
               cleanup:, executable: nil)
  @invocation = invocation
  @environment = Immutable.hash(environment)
  @credential_environment_keys =
    Immutable.strings(credential_environment_keys)
  @invocation_root = Immutable.string(invocation_root)
  @generated_paths = Immutable.strings(generated_paths)
  @configuration_path = Immutable.string(configuration_path)
  @requested_route = requested_route
  @configuration_source =
    configuration_source.nil? ? nil : Immutable.string(configuration_source)
  @probe_result = probe_result
  @executable = Immutable.string(executable || invocation.argv.fetch(0))
  @cleanup = cleanup
  freeze
end

Instance Attribute Details

#configuration_pathObject (readonly)

Returns the value of attribute configuration_path.



369
370
371
# File 'lib/agent_cli_runtime/values.rb', line 369

def configuration_path
  @configuration_path
end

#configuration_sourceObject (readonly)

Returns the value of attribute configuration_source.



369
370
371
# File 'lib/agent_cli_runtime/values.rb', line 369

def configuration_source
  @configuration_source
end

#credential_environment_keysObject (readonly)

Returns the value of attribute credential_environment_keys.



369
370
371
# File 'lib/agent_cli_runtime/values.rb', line 369

def credential_environment_keys
  @credential_environment_keys
end

#environmentObject (readonly)

Returns the value of attribute environment.



369
370
371
# File 'lib/agent_cli_runtime/values.rb', line 369

def environment
  @environment
end

#executableObject (readonly)

Returns the value of attribute executable.



369
370
371
# File 'lib/agent_cli_runtime/values.rb', line 369

def executable
  @executable
end

#generated_pathsObject (readonly)

Returns the value of attribute generated_paths.



369
370
371
# File 'lib/agent_cli_runtime/values.rb', line 369

def generated_paths
  @generated_paths
end

#invocationObject (readonly)

Returns the value of attribute invocation.



369
370
371
# File 'lib/agent_cli_runtime/values.rb', line 369

def invocation
  @invocation
end

#invocation_rootObject (readonly)

Returns the value of attribute invocation_root.



369
370
371
# File 'lib/agent_cli_runtime/values.rb', line 369

def invocation_root
  @invocation_root
end

#probe_resultObject (readonly)

Returns the value of attribute probe_result.



369
370
371
# File 'lib/agent_cli_runtime/values.rb', line 369

def probe_result
  @probe_result
end

#requested_routeObject (readonly)

Returns the value of attribute requested_route.



369
370
371
# File 'lib/agent_cli_runtime/values.rb', line 369

def requested_route
  @requested_route
end

Instance Method Details

#cleanup!Object



402
403
404
405
# File 'lib/agent_cli_runtime/values.rb', line 402

def cleanup!
  @cleanup.call
  nil
end

#environment_for(env: ENV) ⇒ Object



394
395
396
397
398
399
400
# File 'lib/agent_cli_runtime/values.rb', line 394

def environment_for(env: ENV)
  selected = credential_environment_keys.each_with_object({}) do |key, values|
    value = env[key]
    values[key] = value.to_s unless value.to_s.empty?
  end
  selected.merge(environment).freeze
end