ce7cb702218693d08ea6d83464d2457c9250027c
This commit is contained in:
commit
34c5f8963c
1 changed files with 145336 additions and 0 deletions
41
packages/fsharp-runner/oci/Registry.cs
Normal file
41
packages/fsharp-runner/oci/Registry.cs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
using System.Security.Cryptography.X509Certificates;
|
||||
|
||||
namespace Quorate.Oci;
|
||||
|
||||
public sealed class Registry : IDisposable
|
||||
{
|
||||
private readonly RegistryTransport transport;
|
||||
|
||||
public Registry(Uri endpoint, RegistryAuth auth, X509Certificate2 root)
|
||||
{
|
||||
transport = new RegistryTransport(endpoint, auth, root);
|
||||
}
|
||||
|
||||
internal Registry(Uri endpoint, RegistryAuth auth, HttpMessageHandler handler)
|
||||
{
|
||||
transport = new RegistryTransport(endpoint, auth, handler);
|
||||
}
|
||||
|
||||
public static X509Certificate2 LoadRoot(string path) =>
|
||||
X509CertificateLoader.LoadCertificateFromFile(path);
|
||||
|
||||
public async Task<string> PushAsync(
|
||||
string repository,
|
||||
string layout,
|
||||
string sourceTag,
|
||||
string targetTag,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
RepositoryName destination = RepositoryName.Parse(repository);
|
||||
OciTag source = OciTag.Parse(sourceTag);
|
||||
OciTag target = OciTag.Parse(targetTag);
|
||||
OciPublicationPlan plan = await OciLayout.LoadAsync(layout, source, cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
var publisher = new OciPublisher(transport, destination);
|
||||
OciDigest published = await publisher.PushAsync(plan, target, cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
return published.ToString();
|
||||
}
|
||||
|
||||
public void Dispose() => transport.Dispose();
|
||||
}
|
||||
Loading…
Reference in a new issue