Skip to content

Commit

Permalink
resolve merge conflicts
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick Pan <[email protected]>
  • Loading branch information
Patrick Pan committed Nov 26, 2024
2 parents cf431f0 + abdecc3 commit 50e696e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
28 changes: 13 additions & 15 deletions src/OrasProject.Oras/Registry/Remote/ManifestStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,18 +137,17 @@ public async Task<bool> ExistsAsync(Descriptor target, CancellationToken cancell
}

/// <summary>
/// Pushes the content, matching the expected descriptor.
/// Pushes the manifest content, matching the expected descriptor.
/// </summary>
/// <param name="expected"></param>
/// <param name="content"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public async Task PushAsync(Descriptor expected, Stream content, CancellationToken cancellationToken = default)
=> await PushWithIndexingAsync(expected, content, expected.Digest, cancellationToken).ConfigureAwait(false);

=> await PushAsync(expected, content, expected.Digest, cancellationToken).ConfigureAwait(false);

/// <summary>
/// PushReferenceASync pushes the manifest with a reference tag.
/// Pushes the manifest content with a reference tag.
/// </summary>
/// <param name="expected"></param>
/// <param name="content"></param>
Expand All @@ -157,8 +156,8 @@ public async Task PushAsync(Descriptor expected, Stream content, CancellationTok
/// <returns></returns>
public async Task PushAsync(Descriptor expected, Stream content, string reference, CancellationToken cancellationToken = default)
{
var contentReference = Repository.ParseReference(reference).ContentReference!;
await PushWithIndexingAsync(expected, content, contentReference, cancellationToken).ConfigureAwait(false);
var remoteReference = Repository.ParseReference(reference);
await PushWithIndexingAsync(expected, content, remoteReference, cancellationToken).ConfigureAwait(false);
}

/// <summary>
Expand All @@ -171,7 +170,7 @@ public async Task PushAsync(Descriptor expected, Stream content, string referenc
/// <param name="reference"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
private async Task PushWithIndexingAsync(Descriptor expected, Stream content, string reference,
private async Task PushWithIndexingAsync(Descriptor expected, Stream content, Reference reference,
CancellationToken cancellationToken = default)
{
switch (expected.MediaType)
Expand All @@ -181,15 +180,15 @@ private async Task PushWithIndexingAsync(Descriptor expected, Stream content, st
if (Repository.ReferrersSupportLevel == Referrers.ReferrersSupportLevel.ReferrersSupported)
{
// Push the manifest straightaway when the registry supports referrers API
await InternalPushAsync(expected, content, reference, cancellationToken).ConfigureAwait(false);
await DoPushAsync(expected, content, reference, cancellationToken).ConfigureAwait(false);
return;
}

var contentBytes = await content.ReadAllAsync(expected, cancellationToken);
using (var contentDuplicate = new MemoryStream(contentBytes))
{
// Push the manifest when ReferrerState is Unknown or NotSupported
await InternalPushAsync(expected, contentDuplicate, reference, cancellationToken).ConfigureAwait(false);
await DoPushAsync(expected, contentDuplicate, reference, cancellationToken).ConfigureAwait(false);
}
if (Repository.ReferrersSupportLevel == Referrers.ReferrersSupportLevel.ReferrersSupported)
{
Expand All @@ -207,7 +206,7 @@ private async Task PushWithIndexingAsync(Descriptor expected, Stream content, st
}
break;
default:
await InternalPushAsync(expected, content, reference, cancellationToken);
await DoPushAsync(expected, content, reference, cancellationToken);
break;
}
}
Expand Down Expand Up @@ -284,7 +283,7 @@ private async Task UpdateReferrersIndex(Descriptor subject,
var (indexDesc, indexContent) = Index.GenerateIndex(updatedReferrers);
using (var content = new MemoryStream(indexContent))
{
await InternalPushAsync(indexDesc, content, referrersTag, cancellationToken).ConfigureAwait(false);
await DoPushAsync(indexDesc, content, Repository.ParseReference(referrersTag), cancellationToken).ConfigureAwait(false);
}
}

Expand All @@ -307,7 +306,7 @@ private async Task UpdateReferrersIndex(Descriptor subject,
/// <param name="referrersTag"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
internal async Task<(Descriptor, IList<Descriptor>)> PullReferrersIndexList(string referrersTag, CancellationToken cancellationToken = default)
internal async Task<(Descriptor, IList<Descriptor>)> PullReferrersIndexList(String referrersTag, CancellationToken cancellationToken = default)
{
try
{
Expand All @@ -333,9 +332,8 @@ private async Task UpdateReferrersIndex(Descriptor subject,
/// <param name="stream"></param>
/// <param name="contentReference"></param>
/// <param name="cancellationToken"></param>
private async Task InternalPushAsync(Descriptor expected, Stream stream, string contentReference, CancellationToken cancellationToken)
private async Task DoPushAsync(Descriptor expected, Stream stream, Reference remoteReference, CancellationToken cancellationToken)
{
var remoteReference = Repository.ParseReference(contentReference);
var url = new UriFactory(remoteReference, Repository.Options.PlainHttp).BuildRepositoryManifest();
var request = new HttpRequestMessage(HttpMethod.Put, url);
request.Content = new StreamContent(stream);
Expand Down Expand Up @@ -377,7 +375,7 @@ public async Task TagAsync(Descriptor descriptor, string reference, Cancellation
{
var remoteReference = Repository.ParseReference(reference);
using var contentStream = await FetchAsync(descriptor, cancellationToken).ConfigureAwait(false);
await InternalPushAsync(descriptor, contentStream, remoteReference.ContentReference!, cancellationToken).ConfigureAwait(false);
await DoPushAsync(descriptor, contentStream, remoteReference, cancellationToken).ConfigureAwait(false);
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion tests/OrasProject.Oras.Tests/OrasProject.Oras.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
Expand Down

0 comments on commit 50e696e

Please sign in to comment.