28 lines
924 B
C#
28 lines
924 B
C#
using Heimdall.Domain.Enums;
|
|
|
|
namespace Heimdall.Domain.Entities;
|
|
|
|
/// <summary>
|
|
/// Immutable destination details captured when a stored object is written.
|
|
/// Credentials remain in the current secret store and are never persisted here.
|
|
/// </summary>
|
|
public sealed record StorageLocation(
|
|
StorageProvider Provider,
|
|
string? LocalRoot = null,
|
|
string? S3Endpoint = null,
|
|
string? S3Bucket = null)
|
|
{
|
|
public bool IsComplete => Provider switch
|
|
{
|
|
StorageProvider.Local => !string.IsNullOrWhiteSpace(LocalRoot),
|
|
StorageProvider.S3 => IsSafeEndpoint(S3Endpoint) && !string.IsNullOrWhiteSpace(S3Bucket),
|
|
_ => false,
|
|
};
|
|
|
|
private static bool IsSafeEndpoint(string? endpoint) =>
|
|
Uri.TryCreate(endpoint, UriKind.Absolute, out var uri) &&
|
|
string.IsNullOrEmpty(uri.UserInfo) &&
|
|
string.IsNullOrEmpty(uri.Query) &&
|
|
string.IsNullOrEmpty(uri.Fragment);
|
|
}
|