Skip to content

Commit 7699b51

Browse files
committed
WIP: try to define an interface
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent b8c96b9 commit 7699b51

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

cli/command/image/trust.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ func imagePullPrivileged(ctx context.Context, cli command.Cli, imgRefAndAuth tru
289289
}
290290

291291
// TrustedReference returns the canonical trusted reference for an image reference
292-
func TrustedReference(ctx context.Context, cli command.Cli, ref reference.NamedTagged, rs *registry.Service) (reference.Canonical, error) {
292+
func TrustedReference(ctx context.Context, cli command.Cli, ref reference.NamedTagged, rs trust.RepositoryResolver) (reference.Canonical, error) {
293293
imgRefAndAuth, err := trust.GetImageReferencesAndAuth(ctx, rs, AuthResolver(cli), ref.String())
294294
if err != nil {
295295
return nil, err

cli/command/plugin/install.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/docker/cli/cli"
99
"github.com/docker/cli/cli/command"
1010
"github.com/docker/cli/cli/command/image"
11+
"github.com/docker/cli/cli/trust"
1112
"github.com/docker/distribution/reference"
1213
"github.com/docker/docker/api/types"
1314
"github.com/docker/docker/pkg/jsonmessage"
@@ -55,7 +56,7 @@ func newInstallCommand(dockerCli command.Cli) *cobra.Command {
5556
}
5657

5758
type pluginRegistryService struct {
58-
registry.Service
59+
*registry.Service
5960
}
6061

6162
func (s pluginRegistryService) ResolveRepository(name reference.Named) (*registry.RepositoryInfo, error) {
@@ -66,11 +67,12 @@ func (s pluginRegistryService) ResolveRepository(name reference.Named) (*registr
6667
return repoInfo, err
6768
}
6869

69-
func newRegistryService() (registry.Service, error) {
70+
func newRegistryService() (trust.RepositoryResolver, error) {
7071
svc, err := registry.NewService(registry.ServiceOptions{})
7172
if err != nil {
7273
return nil, err
7374
}
75+
// FIXME(thaJeztah); is this correct? (when passing as pointer, it warns: Literal copies a lock value from '*svc': type 'registry.Service' contains 'sync.RWMutex' which is 'sync.Locker'
7476
return pluginRegistryService{Service: svc}, nil
7577
}
7678

cli/trust/trust.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,13 @@ type ImageRefAndAuth struct {
298298
digest digest.Digest
299299
}
300300

301+
type RepositoryResolver interface {
302+
ResolveRepository(name reference.Named) (*registry.RepositoryInfo, error)
303+
}
304+
301305
// GetImageReferencesAndAuth retrieves the necessary reference and auth information for an image name
302306
// as an ImageRefAndAuth struct
303-
func GetImageReferencesAndAuth(ctx context.Context, rs *registry.Service,
307+
func GetImageReferencesAndAuth(ctx context.Context, rs RepositoryResolver,
304308
authResolver func(ctx context.Context, index *registrytypes.IndexInfo) registrytypes.AuthConfig,
305309
imgName string,
306310
) (ImageRefAndAuth, error) {

0 commit comments

Comments
 (0)