up
Some checks failed
Docs CI / lint-and-preview (push) Has been cancelled
AOC Guard CI / aoc-guard (push) Has been cancelled
AOC Guard CI / aoc-verify (push) Has been cancelled
Concelier Attestation Tests / attestation-tests (push) Has been cancelled
Export Center CI / export-ci (push) Has been cancelled
Notify Smoke Test / Notify Unit Tests (push) Has been cancelled
Notify Smoke Test / Notifier Service Tests (push) Has been cancelled
Notify Smoke Test / Notification Smoke Test (push) Has been cancelled
Policy Lint & Smoke / policy-lint (push) Has been cancelled
Scanner Analyzers / Discover Analyzers (push) Has been cancelled
Scanner Analyzers / Build Analyzers (push) Has been cancelled
Scanner Analyzers / Test Language Analyzers (push) Has been cancelled
Scanner Analyzers / Validate Test Fixtures (push) Has been cancelled
Scanner Analyzers / Verify Deterministic Output (push) Has been cancelled
Signals CI & Image / signals-ci (push) Has been cancelled
Signals Reachability Scoring & Events / reachability-smoke (push) Has been cancelled
Signals Reachability Scoring & Events / sign-and-upload (push) Has been cancelled
Some checks failed
Docs CI / lint-and-preview (push) Has been cancelled
AOC Guard CI / aoc-guard (push) Has been cancelled
AOC Guard CI / aoc-verify (push) Has been cancelled
Concelier Attestation Tests / attestation-tests (push) Has been cancelled
Export Center CI / export-ci (push) Has been cancelled
Notify Smoke Test / Notify Unit Tests (push) Has been cancelled
Notify Smoke Test / Notifier Service Tests (push) Has been cancelled
Notify Smoke Test / Notification Smoke Test (push) Has been cancelled
Policy Lint & Smoke / policy-lint (push) Has been cancelled
Scanner Analyzers / Discover Analyzers (push) Has been cancelled
Scanner Analyzers / Build Analyzers (push) Has been cancelled
Scanner Analyzers / Test Language Analyzers (push) Has been cancelled
Scanner Analyzers / Validate Test Fixtures (push) Has been cancelled
Scanner Analyzers / Verify Deterministic Output (push) Has been cancelled
Signals CI & Image / signals-ci (push) Has been cancelled
Signals Reachability Scoring & Events / reachability-smoke (push) Has been cancelled
Signals Reachability Scoring & Events / sign-and-upload (push) Has been cancelled
This commit is contained in:
@@ -1,64 +1,64 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace StellaOps.Configuration;
|
||||
|
||||
public sealed class StellaOpsBootstrapOptions<TOptions>
|
||||
where TOptions : class, new()
|
||||
{
|
||||
public StellaOpsBootstrapOptions()
|
||||
{
|
||||
ConfigurationOptions = new StellaOpsConfigurationOptions();
|
||||
}
|
||||
|
||||
internal StellaOpsConfigurationOptions ConfigurationOptions { get; }
|
||||
|
||||
public string? BasePath
|
||||
{
|
||||
get => ConfigurationOptions.BasePath;
|
||||
set => ConfigurationOptions.BasePath = value;
|
||||
}
|
||||
|
||||
public bool IncludeJsonFiles
|
||||
{
|
||||
get => ConfigurationOptions.IncludeJsonFiles;
|
||||
set => ConfigurationOptions.IncludeJsonFiles = value;
|
||||
}
|
||||
|
||||
public bool IncludeYamlFiles
|
||||
{
|
||||
get => ConfigurationOptions.IncludeYamlFiles;
|
||||
set => ConfigurationOptions.IncludeYamlFiles = value;
|
||||
}
|
||||
|
||||
public bool IncludeEnvironmentVariables
|
||||
{
|
||||
get => ConfigurationOptions.IncludeEnvironmentVariables;
|
||||
set => ConfigurationOptions.IncludeEnvironmentVariables = value;
|
||||
}
|
||||
|
||||
public string? EnvironmentPrefix
|
||||
{
|
||||
get => ConfigurationOptions.EnvironmentPrefix;
|
||||
set => ConfigurationOptions.EnvironmentPrefix = value;
|
||||
}
|
||||
|
||||
public IList<JsonConfigurationFile> JsonFiles => ConfigurationOptions.JsonFiles;
|
||||
|
||||
public IList<YamlConfigurationFile> YamlFiles => ConfigurationOptions.YamlFiles;
|
||||
|
||||
public string? BindingSection
|
||||
{
|
||||
get => ConfigurationOptions.BindingSection;
|
||||
set => ConfigurationOptions.BindingSection = value;
|
||||
}
|
||||
|
||||
public Action<IConfigurationBuilder>? ConfigureBuilder
|
||||
{
|
||||
get => ConfigurationOptions.ConfigureBuilder;
|
||||
set => ConfigurationOptions.ConfigureBuilder = value;
|
||||
}
|
||||
|
||||
public Action<TOptions, IConfiguration>? PostBind { get; set; }
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace StellaOps.Configuration;
|
||||
|
||||
public sealed class StellaOpsBootstrapOptions<TOptions>
|
||||
where TOptions : class, new()
|
||||
{
|
||||
public StellaOpsBootstrapOptions()
|
||||
{
|
||||
ConfigurationOptions = new StellaOpsConfigurationOptions();
|
||||
}
|
||||
|
||||
internal StellaOpsConfigurationOptions ConfigurationOptions { get; }
|
||||
|
||||
public string? BasePath
|
||||
{
|
||||
get => ConfigurationOptions.BasePath;
|
||||
set => ConfigurationOptions.BasePath = value;
|
||||
}
|
||||
|
||||
public bool IncludeJsonFiles
|
||||
{
|
||||
get => ConfigurationOptions.IncludeJsonFiles;
|
||||
set => ConfigurationOptions.IncludeJsonFiles = value;
|
||||
}
|
||||
|
||||
public bool IncludeYamlFiles
|
||||
{
|
||||
get => ConfigurationOptions.IncludeYamlFiles;
|
||||
set => ConfigurationOptions.IncludeYamlFiles = value;
|
||||
}
|
||||
|
||||
public bool IncludeEnvironmentVariables
|
||||
{
|
||||
get => ConfigurationOptions.IncludeEnvironmentVariables;
|
||||
set => ConfigurationOptions.IncludeEnvironmentVariables = value;
|
||||
}
|
||||
|
||||
public string? EnvironmentPrefix
|
||||
{
|
||||
get => ConfigurationOptions.EnvironmentPrefix;
|
||||
set => ConfigurationOptions.EnvironmentPrefix = value;
|
||||
}
|
||||
|
||||
public IList<JsonConfigurationFile> JsonFiles => ConfigurationOptions.JsonFiles;
|
||||
|
||||
public IList<YamlConfigurationFile> YamlFiles => ConfigurationOptions.YamlFiles;
|
||||
|
||||
public string? BindingSection
|
||||
{
|
||||
get => ConfigurationOptions.BindingSection;
|
||||
set => ConfigurationOptions.BindingSection = value;
|
||||
}
|
||||
|
||||
public Action<IConfigurationBuilder>? ConfigureBuilder
|
||||
{
|
||||
get => ConfigurationOptions.ConfigureBuilder;
|
||||
set => ConfigurationOptions.ConfigureBuilder = value;
|
||||
}
|
||||
|
||||
public Action<TOptions, IConfiguration>? PostBind { get; set; }
|
||||
}
|
||||
|
||||
@@ -1,106 +1,106 @@
|
||||
using System;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using NetEscapades.Configuration.Yaml;
|
||||
|
||||
namespace StellaOps.Configuration;
|
||||
|
||||
public static class StellaOpsConfigurationBootstrapper
|
||||
{
|
||||
public static StellaOpsConfigurationContext<TOptions> Build<TOptions>(
|
||||
Action<StellaOpsBootstrapOptions<TOptions>>? configure = null)
|
||||
where TOptions : class, new()
|
||||
{
|
||||
var bootstrapOptions = new StellaOpsBootstrapOptions<TOptions>();
|
||||
configure?.Invoke(bootstrapOptions);
|
||||
|
||||
var configurationOptions = bootstrapOptions.ConfigurationOptions;
|
||||
var builder = new ConfigurationBuilder();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(configurationOptions.BasePath))
|
||||
{
|
||||
builder.SetBasePath(configurationOptions.BasePath!);
|
||||
}
|
||||
|
||||
if (configurationOptions.IncludeJsonFiles)
|
||||
{
|
||||
foreach (var file in configurationOptions.JsonFiles)
|
||||
{
|
||||
builder.AddJsonFile(file.Path, optional: file.Optional, reloadOnChange: file.ReloadOnChange);
|
||||
}
|
||||
}
|
||||
|
||||
if (configurationOptions.IncludeYamlFiles)
|
||||
{
|
||||
foreach (var file in configurationOptions.YamlFiles)
|
||||
{
|
||||
builder.AddYamlFile(file.Path, optional: file.Optional);
|
||||
}
|
||||
}
|
||||
|
||||
configurationOptions.ConfigureBuilder?.Invoke(builder);
|
||||
|
||||
if (configurationOptions.IncludeEnvironmentVariables)
|
||||
{
|
||||
builder.AddEnvironmentVariables(configurationOptions.EnvironmentPrefix);
|
||||
}
|
||||
|
||||
var configuration = builder.Build();
|
||||
|
||||
IConfiguration bindingSource;
|
||||
if (string.IsNullOrWhiteSpace(configurationOptions.BindingSection))
|
||||
{
|
||||
bindingSource = configuration;
|
||||
}
|
||||
else
|
||||
{
|
||||
bindingSource = configuration.GetSection(configurationOptions.BindingSection!);
|
||||
}
|
||||
|
||||
var options = new TOptions();
|
||||
bindingSource.Bind(options);
|
||||
|
||||
bootstrapOptions.PostBind?.Invoke(options, configuration);
|
||||
|
||||
return new StellaOpsConfigurationContext<TOptions>(configuration, options);
|
||||
}
|
||||
|
||||
public static IConfigurationBuilder AddStellaOpsDefaults(
|
||||
this IConfigurationBuilder builder,
|
||||
Action<StellaOpsConfigurationOptions>? configure = null)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(builder);
|
||||
|
||||
var options = new StellaOpsConfigurationOptions();
|
||||
configure?.Invoke(options);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(options.BasePath))
|
||||
{
|
||||
builder.SetBasePath(options.BasePath!);
|
||||
}
|
||||
|
||||
if (options.IncludeJsonFiles)
|
||||
{
|
||||
foreach (var file in options.JsonFiles)
|
||||
{
|
||||
builder.AddJsonFile(file.Path, optional: file.Optional, reloadOnChange: file.ReloadOnChange);
|
||||
}
|
||||
}
|
||||
|
||||
if (options.IncludeYamlFiles)
|
||||
{
|
||||
foreach (var file in options.YamlFiles)
|
||||
{
|
||||
builder.AddYamlFile(file.Path, optional: file.Optional);
|
||||
}
|
||||
}
|
||||
|
||||
options.ConfigureBuilder?.Invoke(builder);
|
||||
|
||||
if (options.IncludeEnvironmentVariables)
|
||||
{
|
||||
builder.AddEnvironmentVariables(options.EnvironmentPrefix);
|
||||
}
|
||||
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using NetEscapades.Configuration.Yaml;
|
||||
|
||||
namespace StellaOps.Configuration;
|
||||
|
||||
public static class StellaOpsConfigurationBootstrapper
|
||||
{
|
||||
public static StellaOpsConfigurationContext<TOptions> Build<TOptions>(
|
||||
Action<StellaOpsBootstrapOptions<TOptions>>? configure = null)
|
||||
where TOptions : class, new()
|
||||
{
|
||||
var bootstrapOptions = new StellaOpsBootstrapOptions<TOptions>();
|
||||
configure?.Invoke(bootstrapOptions);
|
||||
|
||||
var configurationOptions = bootstrapOptions.ConfigurationOptions;
|
||||
var builder = new ConfigurationBuilder();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(configurationOptions.BasePath))
|
||||
{
|
||||
builder.SetBasePath(configurationOptions.BasePath!);
|
||||
}
|
||||
|
||||
if (configurationOptions.IncludeJsonFiles)
|
||||
{
|
||||
foreach (var file in configurationOptions.JsonFiles)
|
||||
{
|
||||
builder.AddJsonFile(file.Path, optional: file.Optional, reloadOnChange: file.ReloadOnChange);
|
||||
}
|
||||
}
|
||||
|
||||
if (configurationOptions.IncludeYamlFiles)
|
||||
{
|
||||
foreach (var file in configurationOptions.YamlFiles)
|
||||
{
|
||||
builder.AddYamlFile(file.Path, optional: file.Optional);
|
||||
}
|
||||
}
|
||||
|
||||
configurationOptions.ConfigureBuilder?.Invoke(builder);
|
||||
|
||||
if (configurationOptions.IncludeEnvironmentVariables)
|
||||
{
|
||||
builder.AddEnvironmentVariables(configurationOptions.EnvironmentPrefix);
|
||||
}
|
||||
|
||||
var configuration = builder.Build();
|
||||
|
||||
IConfiguration bindingSource;
|
||||
if (string.IsNullOrWhiteSpace(configurationOptions.BindingSection))
|
||||
{
|
||||
bindingSource = configuration;
|
||||
}
|
||||
else
|
||||
{
|
||||
bindingSource = configuration.GetSection(configurationOptions.BindingSection!);
|
||||
}
|
||||
|
||||
var options = new TOptions();
|
||||
bindingSource.Bind(options);
|
||||
|
||||
bootstrapOptions.PostBind?.Invoke(options, configuration);
|
||||
|
||||
return new StellaOpsConfigurationContext<TOptions>(configuration, options);
|
||||
}
|
||||
|
||||
public static IConfigurationBuilder AddStellaOpsDefaults(
|
||||
this IConfigurationBuilder builder,
|
||||
Action<StellaOpsConfigurationOptions>? configure = null)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(builder);
|
||||
|
||||
var options = new StellaOpsConfigurationOptions();
|
||||
configure?.Invoke(options);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(options.BasePath))
|
||||
{
|
||||
builder.SetBasePath(options.BasePath!);
|
||||
}
|
||||
|
||||
if (options.IncludeJsonFiles)
|
||||
{
|
||||
foreach (var file in options.JsonFiles)
|
||||
{
|
||||
builder.AddJsonFile(file.Path, optional: file.Optional, reloadOnChange: file.ReloadOnChange);
|
||||
}
|
||||
}
|
||||
|
||||
if (options.IncludeYamlFiles)
|
||||
{
|
||||
foreach (var file in options.YamlFiles)
|
||||
{
|
||||
builder.AddYamlFile(file.Path, optional: file.Optional);
|
||||
}
|
||||
}
|
||||
|
||||
options.ConfigureBuilder?.Invoke(builder);
|
||||
|
||||
if (options.IncludeEnvironmentVariables)
|
||||
{
|
||||
builder.AddEnvironmentVariables(options.EnvironmentPrefix);
|
||||
}
|
||||
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
using System;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace StellaOps.Configuration;
|
||||
|
||||
public sealed class StellaOpsConfigurationContext<TOptions>
|
||||
where TOptions : class, new()
|
||||
{
|
||||
public StellaOpsConfigurationContext(IConfigurationRoot configuration, TOptions options)
|
||||
{
|
||||
Configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
|
||||
Options = options ?? throw new ArgumentNullException(nameof(options));
|
||||
}
|
||||
|
||||
public IConfigurationRoot Configuration { get; }
|
||||
|
||||
public TOptions Options { get; }
|
||||
}
|
||||
using System;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace StellaOps.Configuration;
|
||||
|
||||
public sealed class StellaOpsConfigurationContext<TOptions>
|
||||
where TOptions : class, new()
|
||||
{
|
||||
public StellaOpsConfigurationContext(IConfigurationRoot configuration, TOptions options)
|
||||
{
|
||||
Configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
|
||||
Options = options ?? throw new ArgumentNullException(nameof(options));
|
||||
}
|
||||
|
||||
public IConfigurationRoot Configuration { get; }
|
||||
|
||||
public TOptions Options { get; }
|
||||
}
|
||||
|
||||
@@ -1,49 +1,49 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace StellaOps.Configuration;
|
||||
|
||||
/// <summary>
|
||||
/// Defines how default StellaOps configuration sources are composed.
|
||||
/// </summary>
|
||||
public sealed class StellaOpsConfigurationOptions
|
||||
{
|
||||
public string? BasePath { get; set; } = Directory.GetCurrentDirectory();
|
||||
|
||||
public bool IncludeJsonFiles { get; set; } = true;
|
||||
|
||||
public bool IncludeYamlFiles { get; set; } = true;
|
||||
|
||||
public bool IncludeEnvironmentVariables { get; set; } = true;
|
||||
|
||||
public string? EnvironmentPrefix { get; set; }
|
||||
|
||||
public IList<JsonConfigurationFile> JsonFiles { get; } = new List<JsonConfigurationFile>
|
||||
{
|
||||
new("appsettings.json", true, false),
|
||||
new("appsettings.local.json", true, false)
|
||||
};
|
||||
|
||||
public IList<YamlConfigurationFile> YamlFiles { get; } = new List<YamlConfigurationFile>
|
||||
{
|
||||
new("appsettings.yaml", true),
|
||||
new("appsettings.local.yaml", true)
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Optional hook to register additional configuration sources (e.g. module-specific YAML files).
|
||||
/// </summary>
|
||||
public Action<IConfigurationBuilder>? ConfigureBuilder { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Optional configuration section name used when binding strongly typed options.
|
||||
/// Null or empty indicates the root.
|
||||
/// </summary>
|
||||
public string? BindingSection { get; set; }
|
||||
}
|
||||
|
||||
public sealed record JsonConfigurationFile(string Path, bool Optional = true, bool ReloadOnChange = false);
|
||||
|
||||
public sealed record YamlConfigurationFile(string Path, bool Optional = true);
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace StellaOps.Configuration;
|
||||
|
||||
/// <summary>
|
||||
/// Defines how default StellaOps configuration sources are composed.
|
||||
/// </summary>
|
||||
public sealed class StellaOpsConfigurationOptions
|
||||
{
|
||||
public string? BasePath { get; set; } = Directory.GetCurrentDirectory();
|
||||
|
||||
public bool IncludeJsonFiles { get; set; } = true;
|
||||
|
||||
public bool IncludeYamlFiles { get; set; } = true;
|
||||
|
||||
public bool IncludeEnvironmentVariables { get; set; } = true;
|
||||
|
||||
public string? EnvironmentPrefix { get; set; }
|
||||
|
||||
public IList<JsonConfigurationFile> JsonFiles { get; } = new List<JsonConfigurationFile>
|
||||
{
|
||||
new("appsettings.json", true, false),
|
||||
new("appsettings.local.json", true, false)
|
||||
};
|
||||
|
||||
public IList<YamlConfigurationFile> YamlFiles { get; } = new List<YamlConfigurationFile>
|
||||
{
|
||||
new("appsettings.yaml", true),
|
||||
new("appsettings.local.yaml", true)
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Optional hook to register additional configuration sources (e.g. module-specific YAML files).
|
||||
/// </summary>
|
||||
public Action<IConfigurationBuilder>? ConfigureBuilder { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Optional configuration section name used when binding strongly typed options.
|
||||
/// Null or empty indicates the root.
|
||||
/// </summary>
|
||||
public string? BindingSection { get; set; }
|
||||
}
|
||||
|
||||
public sealed record JsonConfigurationFile(string Path, bool Optional = true, bool ReloadOnChange = false);
|
||||
|
||||
public sealed record YamlConfigurationFile(string Path, bool Optional = true);
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
using System;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace StellaOps.Configuration;
|
||||
|
||||
public static class StellaOpsOptionsBinder
|
||||
{
|
||||
public static TOptions BindOptions<TOptions>(
|
||||
this IConfiguration configuration,
|
||||
string? section = null,
|
||||
Action<TOptions, IConfiguration>? postConfigure = null)
|
||||
where TOptions : class, new()
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(configuration);
|
||||
|
||||
var options = new TOptions();
|
||||
var bindingSource = string.IsNullOrWhiteSpace(section)
|
||||
? configuration
|
||||
: configuration.GetSection(section);
|
||||
|
||||
bindingSource.Bind(options);
|
||||
postConfigure?.Invoke(options, configuration);
|
||||
|
||||
return options;
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace StellaOps.Configuration;
|
||||
|
||||
public static class StellaOpsOptionsBinder
|
||||
{
|
||||
public static TOptions BindOptions<TOptions>(
|
||||
this IConfiguration configuration,
|
||||
string? section = null,
|
||||
Action<TOptions, IConfiguration>? postConfigure = null)
|
||||
where TOptions : class, new()
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(configuration);
|
||||
|
||||
var options = new TOptions();
|
||||
var bindingSource = string.IsNullOrWhiteSpace(section)
|
||||
? configuration
|
||||
: configuration.GetSection(section);
|
||||
|
||||
bindingSource.Bind(options);
|
||||
postConfigure?.Invoke(options, configuration);
|
||||
|
||||
return options;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user