Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor!: modernize registry interface #92

Merged
merged 1 commit into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
namespace OrasProject.Oras.Content;

/// <summary>
/// IPredecessorFinder finds out the nodes directly pointing to a given node of a
/// Finds out the nodes directly pointing to a given node of a
/// directed acyclic graph.
/// In other words, returns the "parents" of the current descriptor.
/// IPredecessorFinder is an extension of Storage.
/// </summary>
public interface IPredecessorFinder
public interface IPredecessorFindable
{
/// <summary>
/// returns the nodes directly pointing to the current node.
Expand Down
2 changes: 1 addition & 1 deletion src/OrasProject.Oras/Content/MemoryGraph.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

namespace OrasProject.Oras.Content;

internal class MemoryGraph : IPredecessorFinder
internal class MemoryGraph : IPredecessorFindable
{
private readonly ConcurrentDictionary<BasicDescriptor, ConcurrentDictionary<BasicDescriptor, Descriptor>> _predecessors = new();

Expand Down
2 changes: 1 addition & 1 deletion src/OrasProject.Oras/Content/MemoryStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

namespace OrasProject.Oras.Content;

public class MemoryStore : ITarget, IPredecessorFinder
public class MemoryStore : ITarget, IPredecessorFindable
{
private readonly MemoryStorage _storage = new();
private readonly MemoryTagStore _tagResolver = new();
Expand Down
51 changes: 0 additions & 51 deletions src/OrasProject.Oras/Interfaces/Registry/IRegistry.cs

This file was deleted.

43 changes: 0 additions & 43 deletions src/OrasProject.Oras/Interfaces/Registry/IRepository.cs

This file was deleted.

57 changes: 0 additions & 57 deletions src/OrasProject.Oras/Interfaces/Registry/IRepositoryOption.cs

This file was deleted.

43 changes: 0 additions & 43 deletions src/OrasProject.Oras/Interfaces/Registry/ITagLister.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@

using OrasProject.Oras.Content;

namespace OrasProject.Oras.Interfaces.Registry
namespace OrasProject.Oras.Registry;

/// <summary>
/// IBlobStore is a CAS with the ability to stat and delete its content.
/// </summary>
public interface IBlobStore : IStorage, IResolvable, IDeletable, IReferenceFetchable
{
/// <summary>
/// IManifestStore is a CAS with the ability to stat and delete its content.
/// Besides, IManifestStore provides reference tagging.
/// </summary>
public interface IManifestStore : IBlobStore, IReferencePusher, ITaggable
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@

using OrasProject.Oras.Content;

namespace OrasProject.Oras.Interfaces.Registry
namespace OrasProject.Oras.Registry;

/// <summary>
/// IManifestStore is a CAS with the ability to stat and delete its content.
/// Besides, IManifestStore provides reference tagging.
/// </summary>
public interface IManifestStore : IBlobStore, IReferencePushable, ITaggable
{
/// <summary>
/// IBlobStore is a CAS with the ability to stat and delete its content.
/// </summary>
public interface IBlobStore : IStorage, IResolvable, IDeletable, IReferenceFetcher
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,18 @@
using System.Threading;
using System.Threading.Tasks;

namespace OrasProject.Oras.Interfaces.Registry
namespace OrasProject.Oras.Registry;

/// <summary>
/// Provides advanced fetch with the tag service.
/// </summary>
public interface IReferenceFetchable
{
/// <summary>
/// IReferenceFetcher provides advanced fetch with the tag service.
/// Fetches the content identified by the reference.
/// </summary>
public interface IReferenceFetcher
{
/// <summary>
/// FetchReferenceAsync fetches the content identified by the reference.
/// </summary>
/// <param name="reference"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<(Descriptor Descriptor, Stream Stream)> FetchReferenceAsync(string reference, CancellationToken cancellationToken = default);
}
/// <param name="reference"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<(Descriptor Descriptor, Stream Stream)> FetchAsync(string reference, CancellationToken cancellationToken = default);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,20 @@
using System.Threading;
using System.Threading.Tasks;

namespace OrasProject.Oras.Interfaces.Registry
namespace OrasProject.Oras.Registry;

/// <summary>
/// Provides advanced push with the tag service.
/// </summary>
public interface IReferencePushable
{
/// <summary>
/// IReferencePusher provides advanced push with the tag service.
/// PushReferenceAsync pushes the manifest with a reference tag.
/// </summary>
public interface IReferencePusher
{
/// <summary>
/// PushReferenceAsync pushes the manifest with a reference tag.
/// </summary>
/// <param name="descriptor"></param>
/// <param name="content"></param>
/// <param name="reference"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task PushReferenceAsync(Descriptor descriptor, Stream content, string reference, CancellationToken cancellationToken = default);
}
/// <param name="descriptor"></param>
/// <param name="content"></param>
/// <param name="reference"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task PushAsync(Descriptor descriptor, Stream content, string reference, CancellationToken cancellationToken = default);
}
49 changes: 49 additions & 0 deletions src/OrasProject.Oras/Registry/IRegistry.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright The ORAS Authors.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;

namespace OrasProject.Oras.Registry;

public interface IRegistry
{
/// <summary>
/// Returns a repository reference by the given name.
/// </summary>
/// <param name="name"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<IRepository> GetRepository(string name, CancellationToken cancellationToken = default);

/// <summary>
/// Repositories lists the name of repositories available in the registry.
/// Since the returned repositories may be paginated by the underlying
/// implementation, a function should be passed in to process the paginated
/// repository list.
/// `last` argument is the `last` parameter when invoking the catalog API.
/// If `last` is NOT empty, the entries in the response start after the
/// repo specified by `last`. Otherwise, the response starts from the top
/// of the Repositories list.
/// Note: When implemented by a remote registry, the catalog API is called.
/// However, not all registries supports pagination or conforms the
/// specification.
/// Reference: https://docs.docker.com/registry/spec/api/#catalog
/// See also `Repositories()` in this package.
/// </summary>
/// <param name="last"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
IAsyncEnumerable<string> ListRepositoriesAsync(string? last = default, CancellationToken cancellationToken = default);
}
Loading
Loading