Module: RSMP::Validator::Configuration
- Includes:
- Loader, Secrets, Validation
- Included in:
- RSMP::Validator
- Defined in:
- lib/rsmp/validator/configuration.rb,
lib/rsmp/validator/configuration/loader.rb,
lib/rsmp/validator/configuration/secrets.rb,
lib/rsmp/validator/configuration/validation.rb
Overview
Handles loading and validating validator configuration files.
Defined Under Namespace
Modules: Loader, Secrets, Validation
Instance Method Summary
collapse
Instance Method Details
#apply_env_overrides!(raw_config) ⇒ Object
28
29
30
31
|
# File 'lib/rsmp/validator/configuration.rb', line 28
def apply_env_overrides!(raw_config)
raw_config['core_version'] = ENV['CORE_VERSION'] if ENV['CORE_VERSION']
raw_config['sxls'] = parse_sxls(ENV['SXLS']) if ENV['SXLS']
end
|
#auto_node_config_path ⇒ Object
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/rsmp/validator/configuration.rb', line 68
def auto_node_config_path
env_key = mode == :site ? 'AUTO_SITE_CONFIG' : 'AUTO_SUPERVISOR_CONFIG'
env_path = ENV.fetch(env_key, nil)
return env_path if env_path && !env_path.empty?
ref_path = 'config/validator.yaml'
return nil unless File.exist? ref_path
config_ref = YAML.load_file ref_path
key = mode == :site ? 'auto_site' : 'auto_supervisor'
path = config_ref[key].to_s.strip
path.empty? ? nil : path
end
|
#get_config(*path, **options) ⇒ Object
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
# File 'lib/rsmp/validator/configuration.rb', line 82
def get_config(*path, **options)
value = config.dig(*path)
return value if value
path_name = path.inspect
default = options[:default]
assume = options[:assume]
if default
warning "Config #{path_name} not found, using default: #{default}"
default
elsif assume
assume
else
raise "Config #{path_name} is missing"
end
end
|
#get_config_path(local: false) ⇒ Object
59
60
61
62
63
64
65
66
|
# File 'lib/rsmp/validator/configuration.rb', line 59
def get_config_path(local: false)
mode_name = mode.to_s
config_path = get_config_path_from_env(mode_name) || get_config_path_from_validator_yaml(mode_name)
abort_with_error "#{mode_name.capitalize} config path not set" unless config_path && config_path != ''
config_path = File.expand_path(config_path) if local
config_path
end
|
#load_auto_node_config ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/rsmp/validator/configuration.rb', line 42
def load_auto_node_config
path = auto_node_config_path
return unless path
@log_stream.puts "Will run auto #{mode} with config: #{path}"
raw_config = load_yaml_config!(
path,
using_message: '',
missing_message: "Auto #{mode} config file #{path} is missing"
)
raw_config['sxls'] = parse_sxls(ENV['SXLS']) if ENV['SXLS']
options_class = auto_node_options_class_for(raw_config)
options = build_options_from_raw(raw_config, path, options_class)
self.auto_node_config = options.to_h
self.auto_node_log_settings = options.log_settings
end
|
#load_tester_config ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/rsmp/validator/configuration.rb', line 14
def load_tester_config
config_path = get_config_path
raw_config = load_yaml_config!(
config_path,
using_message: "Using #{mode} config: #{config_path}",
missing_message: "#{mode.capitalize} config file #{config_path} is missing"
)
apply_env_overrides!(raw_config)
options = build_tester_options(raw_config, config_path)
apply_loaded_config(options)
validate_and_finalize_config!(config_path)
end
|
#validate_and_finalize_config!(config_path) ⇒ Object
33
34
35
36
37
38
39
40
|
# File 'lib/rsmp/validator/configuration.rb', line 33
def validate_and_finalize_config!(config_path)
validate_mode_config!(config_path)
validate_components_config!
validate_timeouts_config!
normalize_core_version!
normalize_sxls!
load_secrets config_path
end
|