Skip to content

Commit

Permalink
refactor!: modernize registry interface (#92)
Browse files Browse the repository at this point in the history
Signed-off-by: Shiwei Zhang <[email protected]>
  • Loading branch information
shizhMSFT authored Jan 2, 2024
1 parent 0b2672f commit 538d214
Show file tree
Hide file tree
Showing 30 changed files with 1,350 additions and 1,310 deletions.
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

0 comments on commit 538d214

Please sign in to comment.