1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #43358 from thaJeztah/plugin_EndpointResolver

plugin: add EndpointResolver interface
This commit is contained in:
Sebastiaan van Stijn 2022-04-21 20:49:56 +02:00 committed by GitHub
commit a189651b4c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 25 deletions

View file

@ -14,7 +14,6 @@ import (
"github.com/containerd/containerd/content"
"github.com/containerd/containerd/content/local"
"github.com/docker/distribution/reference"
"github.com/docker/docker/api/types"
"github.com/docker/docker/pkg/authorization"
"github.com/docker/docker/pkg/containerfs"
@ -41,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)
@ -53,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
@ -83,25 +87,8 @@ type controller struct {
timeoutInSecs int
}
// pluginRegistryService ensures that all resolved repositories
// are of the plugin class.
type pluginRegistryService struct {
registry.Service
}
func (s pluginRegistryService) ResolveRepository(name reference.Named) (repoInfo *registry.RepositoryInfo, err error) {
repoInfo, err = s.Service.ResolveRepository(name)
if repoInfo != nil {
repoInfo.Class = "plugin"
}
return
}
// NewManager returns a new plugin manager.
func NewManager(config ManagerConfig) (*Manager, error) {
if config.RegistryService != nil {
config.RegistryService = pluginRegistryService{config.RegistryService}
}
manager := &Manager{
config: config,
}

View file

@ -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