Method: Bolt::Transport::Orch::Connection#initialize

Defined in:
lib/bolt/transport/orch/connection.rb

#initialize(opts, plan_context, logger) ⇒ Connection

Returns a new instance of Connection.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/bolt/transport/orch/connection.rb', line 19

def initialize(opts, plan_context, logger)
  @logger = logger
  @key = self.class.get_key(opts)
  client_keys = %w[service-url token-file cacert job-poll-interval job-poll-timeout]
  client_opts = client_keys.each_with_object({}) do |k, acc|
    acc[k] = opts[k] if opts.include?(k)
  end
  client_opts['User-Agent'] = "Bolt/#{VERSION}"
  %w[token-file cacert].each do |f|
    client_opts[f] = File.expand_path(client_opts[f]) if client_opts[f]
  end
  logger.debug("Creating orchestrator client for #{client_opts}")
  @client = OrchestratorClient.new(client_opts, true)
  @plan_job = start_plan(plan_context)
  logger.debug("Started plan #{@plan_job}")
  @environment = opts["task-environment"]
end