Browse Source

plugin: add EndpointResolver interface

This defines the interface that the package expects in order to lookup
pull endpoints, instead of requiring the whole registry.Service interface.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn 3 years ago
parent
commit
f9f549cbe4
2 changed files with 9 additions and 7 deletions
  1. 6 1
      plugin/manager.go
  2. 3 6
      plugin/registry.go

+ 6 - 1
plugin/manager.go

@@ -40,6 +40,11 @@ type Executor interface {
 	Signal(id string, signal int) error
 }
 
+// EndpointResolver provides looking up registry endpoints for pulling.
+type EndpointResolver interface {
+	LookupPullEndpoints(hostname string) (endpoints []registry.APIEndpoint, err error)
+}
+
 func (pm *Manager) restorePlugin(p *v2.Plugin, c *controller) error {
 	if p.IsEnabled() {
 		return pm.restore(p, c)
@@ -52,7 +57,7 @@ type eventLogger func(id, name, action string)
 // ManagerConfig defines configuration needed to start new manager.
 type ManagerConfig struct {
 	Store              *Store // remove
-	RegistryService    registry.Service
+	RegistryService    EndpointResolver
 	LiveRestoreEnabled bool // TODO: remove
 	LogPluginEvent     eventLogger
 	Root               string

+ 3 - 6
plugin/registry.go

@@ -7,16 +7,13 @@ import (
 	"net/http"
 	"time"
 
-	"github.com/sirupsen/logrus"
-
-	"github.com/docker/docker/dockerversion"
-
-	"github.com/pkg/errors"
-
 	"github.com/containerd/containerd/remotes"
 	"github.com/containerd/containerd/remotes/docker"
 	"github.com/docker/distribution/reference"
 	"github.com/docker/docker/api/types"
+	"github.com/docker/docker/dockerversion"
+	"github.com/pkg/errors"
+	"github.com/sirupsen/logrus"
 )
 
 // scope builds the correct auth scope for the registry client to authorize against