Class: Contrast::Components::Config::Interface
- Defined in:
- lib/contrast/components/config.rb
Overview
:nodoc: # rubocop:disable Metrics/ClassLength
Constant Summary collapse
- SESSION_VARIABLES =
'Invalid configuration. ' \ "Setting both application.session_id and application.session_metadata is not allowed.\n"
- API_URL =
"Invalid configuration. Missing a required connection value 'url' is not set."
- API_KEY =
"Invalid configuration. Missing a required connection value 'api_key' is not set."
- API_SERVICE_KEY =
"Invalid configuration. Missing a required connection value 'service_tag' is not set."
- API_USERNAME =
"Invalid configuration. Missing a required connection value 'user_name' is not set."
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #agent ⇒ Contrast::Components::Agent::Interface
- #api ⇒ Contrast::Components::Api::Interface
- #application ⇒ Contrast::Components::AppContext::Interface
- #assess ⇒ Contrast::Components::Assess::Interface
- #build ⇒ Object (also: #rebuild)
-
#config_file_path ⇒ String?
The path to the YAML config file, if any.
- #enable ⇒ Object
-
#initialize ⇒ Interface
constructor
A new instance of Interface.
- #invalid? ⇒ Boolean
- #inventory ⇒ Contrast::Components::Inventory::Interface
- #loggable ⇒ Object
- #protect ⇒ Contrast::Components::Protect::Interface
-
#proto_logger ⇒ Object
Basic logger for handling configuration validation logging the file to log is determined by the default one or set by the config file, if that configuration is found.
- #server ⇒ Contrast::Config::ServerConfiguration
-
#session_id ⇒ String?
Typically, this would be accessed through Contrast::SETTINGS, but we’re specifically checking for the user provided value here rather than that echoed back by TeamServer.
-
#session_metadata ⇒ String?
The value of the session metadata set in the configuration, or nil if unset.
- #sources ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize ⇒ Interface
Returns a new instance of Interface.
41 42 43 |
# File 'lib/contrast/components/config.rb', line 41 def initialize build end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
39 40 41 |
# File 'lib/contrast/components/config.rb', line 39 def config @config end |
Instance Method Details
#agent ⇒ Contrast::Components::Agent::Interface
75 76 77 |
# File 'lib/contrast/components/config.rb', line 75 def agent @config.agent end |
#api ⇒ Contrast::Components::Api::Interface
70 71 72 |
# File 'lib/contrast/components/config.rb', line 70 def api @config.api end |
#application ⇒ Contrast::Components::AppContext::Interface
80 81 82 |
# File 'lib/contrast/components/config.rb', line 80 def application @config.application end |
#assess ⇒ Contrast::Components::Assess::Interface
90 91 92 |
# File 'lib/contrast/components/config.rb', line 90 def assess @config.assess end |
#build ⇒ Object Also known as: rebuild
59 60 61 62 63 64 65 66 |
# File 'lib/contrast/components/config.rb', line 59 def build @_valid = nil @config = Contrast::Configuration.new env_overrides validate rescue ArgumentError => e proto_logger.error('[PROTO_LOGGER] Configuration failed with error: ', e) end |
#config_file_path ⇒ String?
Returns the path to the YAML config file, if any.
139 140 141 |
# File 'lib/contrast/components/config.rb', line 139 def config_file_path config.config_file end |
#enable ⇒ Object
109 110 111 |
# File 'lib/contrast/components/config.rb', line 109 def enable @config.enable end |
#invalid? ⇒ Boolean
117 118 119 |
# File 'lib/contrast/components/config.rb', line 117 def invalid? !valid? end |
#inventory ⇒ Contrast::Components::Inventory::Interface
95 96 97 |
# File 'lib/contrast/components/config.rb', line 95 def inventory @config.inventory end |
#loggable ⇒ Object
121 122 123 |
# File 'lib/contrast/components/config.rb', line 121 def loggable @config.loggable end |
#protect ⇒ Contrast::Components::Protect::Interface
100 101 102 |
# File 'lib/contrast/components/config.rb', line 100 def protect @config.protect end |
#proto_logger ⇒ Object
Basic logger for handling configuration validation logging the file to log is determined by the default one or set by the config file, if that configuration is found
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/contrast/components/config.rb', line 48 def proto_logger @_proto_logger ||= begin @_proto_logger = ::Ougai::Logger.new(logger_path || CONTRAST_LOG) @_proto_logger.progname = CONTRAST_NAME @_proto_logger.level = ::Ougai::Logging::Severity::WARN @_proto_logger.formatter = Contrast::Logger::Format.new @_proto_logger.formatter.datetime_format = DATE_TIME @_proto_logger end end |
#server ⇒ Contrast::Config::ServerConfiguration
85 86 87 |
# File 'lib/contrast/components/config.rb', line 85 def server @config.server end |
#session_id ⇒ String?
Typically, this would be accessed through Contrast::SETTINGS, but we’re specifically checking for the user provided value here rather than that echoed back by TeamServer.
129 130 131 |
# File 'lib/contrast/components/config.rb', line 129 def session_id application.session_id end |
#session_metadata ⇒ String?
Returns the value of the session metadata set in the configuration, or nil if unset.
134 135 136 |
# File 'lib/contrast/components/config.rb', line 134 def application. end |
#sources ⇒ Object
113 114 115 |
# File 'lib/contrast/components/config.rb', line 113 def sources @config.sources end |
#valid? ⇒ Boolean
104 105 106 107 |
# File 'lib/contrast/components/config.rb', line 104 def valid? @_valid = validate if @_valid.nil? @_valid end |