Skip to content

Commit 8d2b306

Browse files
AkihiroSudaaustinvazquez
authored andcommitted
fs/source: drop indirect dependency on k8s.io/cri-api
nerdctl imports `soci-snapshotter/fs/source` but does not want to import k8s.io/cri-api See containerd/nerdctl PR 2761 Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
1 parent 9731bb2 commit 8d2b306

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

fs/source/source.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ import (
3838
"strconv"
3939
"strings"
4040

41-
"github.com/awslabs/soci-snapshotter/service/resolver"
4241
"github.com/containerd/containerd/images"
4342
"github.com/containerd/containerd/labels"
4443
ctdsnapshotters "github.com/containerd/containerd/pkg/snapshotters"
@@ -87,9 +86,13 @@ const (
8786
TargetSociIndexDigestLabel = "containerd.io/snapshot/remote/soci.index.digest"
8887
)
8988

89+
// RegistryHosts is copied from [github.com/awslabs/soci-snapshotter/service/resolver.RegistryHosts]
90+
// to reduce package dependency
91+
type RegistryHosts func(imgRefSpec reference.Spec) ([]docker.RegistryHost, error)
92+
9093
// FromDefaultLabels returns a function for converting snapshot labels to
9194
// source information based on labels.
92-
func FromDefaultLabels(hosts resolver.RegistryHosts) GetSources {
95+
func FromDefaultLabels(hosts RegistryHosts) GetSources {
9396
return func(labels map[string]string) ([]Source, error) {
9497
refStr, ok := labels[ctdsnapshotters.TargetRefLabel]
9598
if !ok {

service/service.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func NewSociSnapshotterService(ctx context.Context, root string, serviceCfg *con
100100
}
101101
// Configure filesystem and snapshotter
102102
fsOpts := append(sOpts.fsOpts, socifs.WithGetSources(
103-
source.FromDefaultLabels(hosts), // provides source info based on default labels
103+
source.FromDefaultLabels(source.RegistryHosts(hosts)), // provides source info based on default labels
104104
), socifs.WithOverlayOpaqueType(opq))
105105
fs, err := socifs.NewFilesystem(ctx, fsRoot(root), serviceCfg.FSConfig, fsOpts...)
106106
if err != nil {

0 commit comments

Comments
 (0)