This directory contains a shared configuration parsing and marshalling framework used by various ATS components including traffic_server and traffic_ctl.
Each configuration file type (ssl_multicert, etc.) follows the same pattern:
include/config/<config_name>.h - Header with data types, parser, marshaller src/config/<config_name>.cc - Implementation
For each configuration type, there are three main components:
Entry struct - A POD (plain old data) type representing a single configuration entry (e.g., SSLMultiCertEntry).
Parser class - Reads configuration files and returns parsed entries. Supports both YAML and legacy formats with automatic format detection.
Marshaller class - Serializes configuration to YAML or JSON format.
include/config/ssl_multicert.h ├── SSLMultiCertEntry - Single certificate entry ├── SSLMultiCertConfig - Vector of entries (type alias) ├── ConfigResult<T> - Parse result with error handling ├── SSLMultiCertParser - Parser for .yaml and .config formats └── SSLMultiCertMarshaller - Serializer to YAML/JSON
#include "config/ssl_multicert.h" config::SSLMultiCertParser parser; auto result = parser.parse("/path/to/ssl_multicert.yaml"); if (!result.ok()) { // Handle error - result.errata contains error details return; } for (const auto& entry : result.value) { // Use entry.ssl_cert_name, entry.dest_ip, etc. }
config::SSLMultiCertMarshaller marshaller; std::string yaml = marshaller.to_yaml(result.value); std::string json = marshaller.to_json(result.value);
The parser automatically detects the configuration format:
.yaml/.yml → YAML, .config → Legacyssl_multicert: (YAML) vs key=value (Legacy)To add support for a new configuration (maybe, logging.yaml):
Create include/config/logging.h:
LoggingEntry struct with fields matching the configLoggingConfig = std::vector<LoggingEntry>LoggingParser and LoggingMarshaller classesCreate src/config/logging.cc:
Update src/config/CMakeLists.txt:
logging.cc to the library sourcesCONFIG_PUBLIC_HEADERSIntegrate with consumers (traffic_ctl, traffic_server, etc.)
All parsers return ConfigResult<T> which contains:
value - The parsed configuration (valid even on partial failure)errata - Error/warning information using swoc::Errataok() - Returns true if no errors occurredif (!result.ok()) { if (!result.errata.empty()) { std::cerr << result.errata.front().text() << std::endl; } }
swoc::Errata)Build with testing enabled and run:
cmake -B build -DBUILD_TESTING=ON ... cmake --build build --target test_tsconfig ctest --test-dir build -R test_tsconfig