Files
Heimdall/src/Heimdall.Domain/Entities/StorageLocation.cs
T
Arnaud Dartois 2b41ab4ea3
Heimdall Gitea / Build and tests (pull_request) Failing after 4m57s
Heimdall Gitea / Publish versioned release (pull_request) Skipped
fix(storage): record historical object destinations
2026-10-22 19:58:55 +02:00

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);
}