up
This commit is contained in:
@@ -19,7 +19,7 @@ internal sealed record SuseCursor(
|
||||
|
||||
public static SuseCursor Empty { get; } = new(null, EmptyStringList, EmptyGuidList, EmptyGuidList, EmptyCache);
|
||||
|
||||
public static SuseCursor FromBson(DocumentObject? document)
|
||||
public static SuseCursor FromDocument(DocumentObject? document)
|
||||
{
|
||||
if (document is null || document.ElementCount == 0)
|
||||
{
|
||||
@@ -168,7 +168,7 @@ internal sealed record SuseCursor(
|
||||
{
|
||||
if (element.Value is DocumentObject entry)
|
||||
{
|
||||
cache[element.Name] = SuseFetchCacheEntry.FromBson(entry);
|
||||
cache[element.Name] = SuseFetchCacheEntry.FromDocument(entry);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using System;
|
||||
using StellaOps.Concelier.Documents;
|
||||
using MongoContracts = StellaOps.Concelier.Storage;
|
||||
using LegacyContracts = StellaOps.Concelier.Storage;
|
||||
using StorageContracts = StellaOps.Concelier.Storage.Contracts;
|
||||
|
||||
namespace StellaOps.Concelier.Connector.Distro.Suse.Internal;
|
||||
@@ -12,10 +12,10 @@ internal sealed record SuseFetchCacheEntry(string? ETag, DateTimeOffset? LastMod
|
||||
public static SuseFetchCacheEntry FromDocument(StorageContracts.StorageDocument document)
|
||||
=> new(document.Etag, document.LastModified);
|
||||
|
||||
public static SuseFetchCacheEntry FromDocument(MongoContracts.DocumentRecord document)
|
||||
public static SuseFetchCacheEntry FromDocument(LegacyContracts.DocumentRecord document)
|
||||
=> new(document.Etag, document.LastModified);
|
||||
|
||||
public static SuseFetchCacheEntry FromBson(DocumentObject document)
|
||||
public static SuseFetchCacheEntry FromDocument(DocumentObject document)
|
||||
{
|
||||
if (document is null || document.ElementCount == 0)
|
||||
{
|
||||
@@ -79,7 +79,7 @@ internal sealed record SuseFetchCacheEntry(string? ETag, DateTimeOffset? LastMod
|
||||
return !LastModified.HasValue && !document.LastModified.HasValue;
|
||||
}
|
||||
|
||||
public bool Matches(MongoContracts.DocumentRecord document)
|
||||
public bool Matches(LegacyContracts.DocumentRecord document)
|
||||
{
|
||||
if (document is null)
|
||||
{
|
||||
|
||||
@@ -343,7 +343,7 @@ public sealed class SuseConnector : IFeedConnector
|
||||
var updatedDocument = document with { Metadata = metadata };
|
||||
await _documentStore.UpsertAsync(updatedDocument, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var payload = ToBson(dto);
|
||||
var payload = ToDocument(dto);
|
||||
var dtoRecord = new DtoRecord(Guid.NewGuid(), document.Id, SourceName, "suse.csaf.v1", payload, _timeProvider.GetUtcNow());
|
||||
|
||||
await _dtoStore.UpsertAsync(dtoRecord, cancellationToken).ConfigureAwait(false);
|
||||
@@ -390,7 +390,7 @@ public sealed class SuseConnector : IFeedConnector
|
||||
SuseAdvisoryDto dto;
|
||||
try
|
||||
{
|
||||
dto = FromBson(dtoRecord.Payload);
|
||||
dto = FromDocument(dtoRecord.Payload);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -415,7 +415,7 @@ public sealed class SuseConnector : IFeedConnector
|
||||
private async Task<SuseCursor> GetCursorAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
var state = await _stateRepository.TryGetAsync(SourceName, cancellationToken).ConfigureAwait(false);
|
||||
return state is null ? SuseCursor.Empty : SuseCursor.FromBson(state.Cursor);
|
||||
return state is null ? SuseCursor.Empty : SuseCursor.FromDocument(state.Cursor);
|
||||
}
|
||||
|
||||
private async Task UpdateCursorAsync(SuseCursor cursor, CancellationToken cancellationToken)
|
||||
@@ -424,7 +424,7 @@ public sealed class SuseConnector : IFeedConnector
|
||||
await _stateRepository.UpdateCursorAsync(SourceName, document, _timeProvider.GetUtcNow(), cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private static DocumentObject ToBson(SuseAdvisoryDto dto)
|
||||
private static DocumentObject ToDocument(SuseAdvisoryDto dto)
|
||||
{
|
||||
var packages = new DocumentArray();
|
||||
foreach (var package in dto.Packages)
|
||||
@@ -493,7 +493,7 @@ public sealed class SuseConnector : IFeedConnector
|
||||
};
|
||||
}
|
||||
|
||||
private static SuseAdvisoryDto FromBson(DocumentObject document)
|
||||
private static SuseAdvisoryDto FromDocument(DocumentObject document)
|
||||
{
|
||||
var advisoryId = document.GetValue("advisoryId", string.Empty).AsString;
|
||||
var title = document.GetValue("title", advisoryId).AsString;
|
||||
@@ -507,8 +507,8 @@ public sealed class SuseConnector : IFeedConnector
|
||||
}
|
||||
: DateTimeOffset.UtcNow;
|
||||
|
||||
var cves = document.TryGetValue("cves", out var cveArray) && cveArray is DocumentArray bsonCves
|
||||
? bsonCves.OfType<DocumentValue>()
|
||||
var cves = document.TryGetValue("cves", out var cveArray) && cveArray is DocumentArray cveArr
|
||||
? cveArr.OfType<DocumentValue>()
|
||||
.Select(static value => value?.ToString())
|
||||
.Where(static value => !string.IsNullOrWhiteSpace(value))
|
||||
.Select(static value => value!)
|
||||
@@ -517,9 +517,9 @@ public sealed class SuseConnector : IFeedConnector
|
||||
: Array.Empty<string>();
|
||||
|
||||
var packageList = new List<SusePackageStateDto>();
|
||||
if (document.TryGetValue("packages", out var packageArray) && packageArray is DocumentArray bsonPackages)
|
||||
if (document.TryGetValue("packages", out var packageArray) && packageArray is DocumentArray packageArr)
|
||||
{
|
||||
foreach (var element in bsonPackages.OfType<DocumentObject>())
|
||||
foreach (var element in packageArr.OfType<DocumentObject>())
|
||||
{
|
||||
var package = element.GetValue("package", string.Empty).AsString;
|
||||
var platform = element.GetValue("platform", string.Empty).AsString;
|
||||
@@ -544,9 +544,9 @@ public sealed class SuseConnector : IFeedConnector
|
||||
}
|
||||
|
||||
var referenceList = new List<SuseReferenceDto>();
|
||||
if (document.TryGetValue("references", out var referenceArray) && referenceArray is DocumentArray bsonReferences)
|
||||
if (document.TryGetValue("references", out var referenceArray) && referenceArray is DocumentArray referenceArr)
|
||||
{
|
||||
foreach (var element in bsonReferences.OfType<DocumentObject>())
|
||||
foreach (var element in referenceArr.OfType<DocumentObject>())
|
||||
{
|
||||
var url = element.GetValue("url", string.Empty).AsString;
|
||||
if (string.IsNullOrWhiteSpace(url))
|
||||
|
||||
Reference in New Issue
Block a user