feat: add startup config validation and document ConfigManager pipeline editor
Add ConfigurationValidationRunner with IConfigurationValidator interface for validating required settings at startup. Includes SecureStore and LDAP validators. Expand ConfigManager with pipeline editing UI, dialogs, and step editors. Update documentation with config validation guidance.
This commit is contained in:
@@ -105,6 +105,86 @@ builder.Services.Configure<DataSourceOptions>(builder.Configuration.GetSection("
|
||||
builder.Services.Configure<AuthOptions>(builder.Configuration.GetSection("Auth"));
|
||||
```
|
||||
|
||||
## Configuration Validation
|
||||
|
||||
The application validates configuration at startup using `ConfigurationValidationRunner`. This catches configuration errors early, before the application attempts to use misconfigured services.
|
||||
|
||||
### How validation works
|
||||
|
||||
1. The runner resolves all `IConfigurationValidator` implementations from DI
|
||||
2. Validators execute in order (sorted by `Order` property, lower values run first)
|
||||
3. Each validator returns a `ConfigurationValidationResult` with errors and warnings
|
||||
4. Warnings are logged but don't prevent startup
|
||||
5. Errors cause startup to fail with detailed logging
|
||||
|
||||
### Built-in validators
|
||||
|
||||
| Validator | Order | Purpose |
|
||||
|-----------|-------|---------|
|
||||
| `SecureStoreValidator` | 100 | Validates required secrets exist in the SecureStore |
|
||||
| `LdapOptionsValidator` | 200 | Validates LDAP configuration settings |
|
||||
|
||||
### Creating a new validator
|
||||
|
||||
Implement `IConfigurationValidator` in `JdeScoping.Infrastructure/Validation/`:
|
||||
|
||||
```csharp
|
||||
using JdeScoping.Core.Validation;
|
||||
|
||||
public class MyOptionsValidator : IConfigurationValidator
|
||||
{
|
||||
private readonly MyOptions _options;
|
||||
|
||||
public int Order => 300; // Run after existing validators
|
||||
public string Name => "MyOptions";
|
||||
|
||||
public MyOptionsValidator(IOptions<MyOptions> options)
|
||||
{
|
||||
_options = options.Value;
|
||||
}
|
||||
|
||||
public ConfigurationValidationResult Validate()
|
||||
{
|
||||
var result = new ConfigurationValidationResult(Name);
|
||||
|
||||
if (string.IsNullOrEmpty(_options.RequiredSetting))
|
||||
result.AddError("RequiredSetting must be configured");
|
||||
|
||||
if (_options.Timeout < 1000)
|
||||
result.AddWarning("Timeout below 1000ms may cause issues");
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Register the validator in `DependencyInjection.cs`:
|
||||
|
||||
```csharp
|
||||
services.AddSingleton<IConfigurationValidator, MyOptionsValidator>();
|
||||
```
|
||||
|
||||
The runner automatically discovers and executes all registered validators.
|
||||
|
||||
### Validation result types
|
||||
|
||||
- **Errors** - Fatal configuration problems that prevent startup. Use `result.AddError()` for missing required settings, invalid values, or conditions that would cause runtime failures.
|
||||
- **Warnings** - Non-fatal issues that should be logged but allow startup. Use `result.AddWarning()` for suboptimal settings or deprecated configurations.
|
||||
|
||||
### Order conventions
|
||||
|
||||
Follow these conventions for the `Order` property:
|
||||
|
||||
| Range | Purpose |
|
||||
|-------|---------|
|
||||
| 100 | Security/secrets (SecureStore) |
|
||||
| 200 | Authentication (LDAP) |
|
||||
| 300-399 | Data sources and connections |
|
||||
| 400-499 | Service-specific validation |
|
||||
| 500+ | Application-level validation |
|
||||
|
||||
Lower-ordered validators run first, allowing dependent validators to assume earlier validations passed.
|
||||
|
||||
## Data Source Configuration
|
||||
|
||||
The JDE and CMS data sources support two implementations:
|
||||
|
||||
Reference in New Issue
Block a user