CollectorConfig.withFallback constructor
CollectorConfig.withFallback({
- required YamlMap? yaml,
- required YamlMap fallback,
Factory constructor that parses a YAML map into CollectorConfig. Uses a fallback configuration if the provided YAML is missing any fields.
Implementation
factory CollectorConfig.withFallback(
{required YamlMap? yaml, required YamlMap fallback}) {
final inputRoot = yaml?['input_root'] ?? fallback['input_root'];
final outputRoot = yaml?['output_root'] ?? fallback['output_root'];
final patterns = yaml?['patterns'] ?? fallback['patterns'];
final outputPreservePathFrom =
yaml?['preserve_path_from'] ?? fallback['preserve_path_from'];
final patternsStringRegex = patterns['string_regex'];
final excludePaths = _readList(patterns['exclude_paths'] as YamlList);
final excludeLinePatterns =
_readList(patterns['exclude_lines'] as YamlList);
return CollectorConfig(
inputRoot: inputRoot as String,
outputRoot: outputRoot as String,
preservePathFrom: outputPreservePathFrom as String,
patternsStringRegex: patternsStringRegex as String,
excludePaths: excludePaths,
patternsExcludeLine: excludeLinePatterns,
);
}