release orchestration strengthening
This commit is contained in:
@@ -708,6 +708,80 @@ public sealed class InMemoryVexObservationStore : IVexObservationStore
|
||||
: 0;
|
||||
return ValueTask.FromResult((long)count);
|
||||
}
|
||||
|
||||
public ValueTask<bool> UpdateRekorLinkageAsync(
|
||||
string tenant,
|
||||
string observationId,
|
||||
RekorLinkage linkage,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(tenant);
|
||||
ArgumentNullException.ThrowIfNull(observationId);
|
||||
ArgumentNullException.ThrowIfNull(linkage);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
if (!_tenants.TryGetValue(tenant, out var store) || !store.TryGetValue(observationId, out var observation))
|
||||
{
|
||||
return ValueTask.FromResult(false);
|
||||
}
|
||||
|
||||
var updated = observation with
|
||||
{
|
||||
RekorUuid = linkage.Uuid,
|
||||
RekorLogIndex = linkage.LogIndex,
|
||||
RekorIntegratedTime = linkage.IntegratedTime,
|
||||
RekorLogUrl = linkage.LogUrl,
|
||||
RekorInclusionProof = linkage.InclusionProof,
|
||||
RekorLinkedAt = linkage.LinkedAt
|
||||
};
|
||||
|
||||
store[observationId] = updated;
|
||||
return ValueTask.FromResult(true);
|
||||
}
|
||||
|
||||
public ValueTask<IReadOnlyList<VexObservation>> GetPendingRekorAttestationAsync(
|
||||
string tenant,
|
||||
int limit,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
if (limit <= 0)
|
||||
{
|
||||
limit = 50;
|
||||
}
|
||||
|
||||
var results = _tenants.TryGetValue(tenant, out var store)
|
||||
? store.Values
|
||||
.Where(o => string.IsNullOrWhiteSpace(o.RekorUuid))
|
||||
.OrderBy(o => o.CreatedAt)
|
||||
.Take(limit)
|
||||
.ToList()
|
||||
: new List<VexObservation>();
|
||||
|
||||
return ValueTask.FromResult<IReadOnlyList<VexObservation>>(results);
|
||||
}
|
||||
|
||||
public ValueTask<VexObservation?> GetByRekorUuidAsync(
|
||||
string tenant,
|
||||
string rekorUuid,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(tenant);
|
||||
ArgumentNullException.ThrowIfNull(rekorUuid);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
if (!_tenants.TryGetValue(tenant, out var store))
|
||||
{
|
||||
return ValueTask.FromResult<VexObservation?>(null);
|
||||
}
|
||||
|
||||
var result = store.Values.FirstOrDefault(o =>
|
||||
!string.IsNullOrWhiteSpace(o.RekorUuid) &&
|
||||
string.Equals(o.RekorUuid, rekorUuid, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
return ValueTask.FromResult(result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -735,12 +735,12 @@ public sealed class PostgresVexObservationStore : RepositoryBase<ExcititorDataSo
|
||||
await using var command = CreateCommand(sql, connection);
|
||||
command.Parameters.AddWithValue("tenant", tenant.ToLowerInvariant());
|
||||
command.Parameters.AddWithValue("observation_id", observationId);
|
||||
command.Parameters.AddWithValue("rekor_uuid", linkage.EntryUuid ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("rekor_log_index", linkage.LogIndex ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("rekor_integrated_time", linkage.IntegratedTime ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("rekor_uuid", linkage.Uuid ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("rekor_log_index", linkage.LogIndex);
|
||||
command.Parameters.AddWithValue("rekor_integrated_time", linkage.IntegratedTime);
|
||||
command.Parameters.AddWithValue("rekor_log_url", linkage.LogUrl ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("rekor_tree_root", linkage.InclusionProof?.TreeRoot ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("rekor_tree_size", linkage.InclusionProof?.TreeSize ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("rekor_tree_root", linkage.TreeRoot ?? (object)DBNull.Value);
|
||||
command.Parameters.AddWithValue("rekor_tree_size", linkage.TreeSize ?? (object)DBNull.Value);
|
||||
|
||||
var inclusionProofJson = linkage.InclusionProof is not null
|
||||
? JsonSerializer.Serialize(linkage.InclusionProof)
|
||||
@@ -786,7 +786,7 @@ public sealed class PostgresVexObservationStore : RepositoryBase<ExcititorDataSo
|
||||
|
||||
while (await reader.ReadAsync(cancellationToken).ConfigureAwait(false))
|
||||
{
|
||||
var observation = MapReaderToObservation(reader);
|
||||
var observation = Map(reader);
|
||||
if (observation is not null)
|
||||
{
|
||||
results.Add(observation);
|
||||
@@ -833,7 +833,7 @@ public sealed class PostgresVexObservationStore : RepositoryBase<ExcititorDataSo
|
||||
|
||||
private VexObservation? MapReaderToObservationWithRekor(NpgsqlDataReader reader)
|
||||
{
|
||||
var observation = MapReaderToObservation(reader);
|
||||
var observation = Map(reader);
|
||||
if (observation is null)
|
||||
{
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user