Class: Chef::Reporting::StartHandler

Inherits:
Handler
  • Object
show all
Defined in:
lib/chef_reporting/start_handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ StartHandler

Returns a new instance of StartHandler.



29
30
31
# File 'lib/chef_reporting/start_handler.rb', line 29

def initialize(config={})
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



27
28
29
# File 'lib/chef_reporting/start_handler.rb', line 27

def config
  @config
end

Instance Method Details

#reportObject



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/chef_reporting/start_handler.rb', line 33

def report
  version_checker = Chef::VersionConstraint.new("< 11.6.0")
  if version_checker.include?(Chef::VERSION)
    Chef::Log.info("Enabling backported resource reporting Handler")
    rest = Chef::REST.new(Chef::Config[:chef_server_url], @run_status.node.name, Chef::Config[:client_key])
    resource_reporter = Chef::Reporting::ResourceReporter.new(rest)
    @run_status.events.register(resource_reporter)

    resource_reporter.run_started(@run_status)
  else
    Chef::Log.debug("Chef Version already has new Resource Reporter - skipping startup of backport version")
  end
end