using System;

namespace StellaOps.Configuration;

public sealed class AuthoritySigningAdditionalKeyOptions
{
    public string KeyId { get; set; } = string.Empty;

    public string Path { get; set; } = string.Empty;

    public string? Source { get; set; }

    internal void Validate(string defaultSource)
    {
        if (string.IsNullOrWhiteSpace(KeyId))
        {
            throw new InvalidOperationException("Additional signing keys require a keyId.");
        }

        if (string.IsNullOrWhiteSpace(Path))
        {
            throw new InvalidOperationException($"Signing key '{KeyId}' requires a path.");
        }

        if (string.IsNullOrWhiteSpace(Source))
        {
            Source = defaultSource;
        }
    }
}
