mirror of
https://github.com/inspec/inspec
synced 2024-11-27 15:10:44 +00:00
Handle load_config better
private method to minimize external interface default enabled to false if unable to find setting in configuration add reader for config Signed-off-by: Miah Johnson <miah@chia-pet.org>
This commit is contained in:
parent
6881c210ad
commit
ea0643cc14
1 changed files with 12 additions and 7 deletions
|
@ -7,6 +7,8 @@ module Inspec::Telemetry
|
||||||
class Collector
|
class Collector
|
||||||
include Singleton
|
include Singleton
|
||||||
|
|
||||||
|
attr_reader :config
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@data_series = []
|
@data_series = []
|
||||||
load_config
|
load_config
|
||||||
|
@ -23,15 +25,11 @@ module Inspec::Telemetry
|
||||||
@data_series << data_series
|
@data_series << data_series
|
||||||
end
|
end
|
||||||
|
|
||||||
# Is the Telemetry system enabled or disabled?
|
# The loaded configuration should have a option to configure
|
||||||
# Always true until we add configuration parsing.
|
# telemetry, if not default to false.
|
||||||
# @return [True, False]
|
# @return [True, False]
|
||||||
def telemetry_enabled?
|
def telemetry_enabled?
|
||||||
if @config.telemetry_enabled?.nil?
|
config_telemetry_options.fetch("enable_telemetry", false)
|
||||||
@enabled = true
|
|
||||||
else
|
|
||||||
@enabled = @config.telemetry_enabled?
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# A way to disable the telemetry system.
|
# A way to disable the telemetry system.
|
||||||
|
@ -66,5 +64,12 @@ module Inspec::Telemetry
|
||||||
def reset
|
def reset
|
||||||
@data_series = []
|
@data_series = []
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
# Minimize exposure of Inspec::Config interface
|
||||||
|
def config_telemetry_options
|
||||||
|
config.telemetry_options
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue