Merge pull request #43358 from thaJeztah/plugin_EndpointResolver
plugin: add EndpointResolver interface
This commit is contained in:
commit
a189651b4c
|
@ -14,7 +14,6 @@ import (
|
||||||
|
|
||||||
"github.com/containerd/containerd/content"
|
"github.com/containerd/containerd/content"
|
||||||
"github.com/containerd/containerd/content/local"
|
"github.com/containerd/containerd/content/local"
|
||||||
"github.com/docker/distribution/reference"
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/pkg/authorization"
|
"github.com/docker/docker/pkg/authorization"
|
||||||
"github.com/docker/docker/pkg/containerfs"
|
"github.com/docker/docker/pkg/containerfs"
|
||||||
|
@ -41,6 +40,11 @@ type Executor interface {
|
||||||
Signal(id string, signal int) error
|
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 {
|
func (pm *Manager) restorePlugin(p *v2.Plugin, c *controller) error {
|
||||||
if p.IsEnabled() {
|
if p.IsEnabled() {
|
||||||
return pm.restore(p, c)
|
return pm.restore(p, c)
|
||||||
|
@ -53,7 +57,7 @@ type eventLogger func(id, name, action string)
|
||||||
// ManagerConfig defines configuration needed to start new manager.
|
// ManagerConfig defines configuration needed to start new manager.
|
||||||
type ManagerConfig struct {
|
type ManagerConfig struct {
|
||||||
Store *Store // remove
|
Store *Store // remove
|
||||||
RegistryService registry.Service
|
RegistryService EndpointResolver
|
||||||
LiveRestoreEnabled bool // TODO: remove
|
LiveRestoreEnabled bool // TODO: remove
|
||||||
LogPluginEvent eventLogger
|
LogPluginEvent eventLogger
|
||||||
Root string
|
Root string
|
||||||
|
@ -83,25 +87,8 @@ type controller struct {
|
||||||
timeoutInSecs int
|
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.
|
// NewManager returns a new plugin manager.
|
||||||
func NewManager(config ManagerConfig) (*Manager, error) {
|
func NewManager(config ManagerConfig) (*Manager, error) {
|
||||||
if config.RegistryService != nil {
|
|
||||||
config.RegistryService = pluginRegistryService{config.RegistryService}
|
|
||||||
}
|
|
||||||
manager := &Manager{
|
manager := &Manager{
|
||||||
config: config,
|
config: config,
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,16 +7,13 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
|
|
||||||
"github.com/docker/docker/dockerversion"
|
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
|
|
||||||
"github.com/containerd/containerd/remotes"
|
"github.com/containerd/containerd/remotes"
|
||||||
"github.com/containerd/containerd/remotes/docker"
|
"github.com/containerd/containerd/remotes/docker"
|
||||||
"github.com/docker/distribution/reference"
|
"github.com/docker/distribution/reference"
|
||||||
"github.com/docker/docker/api/types"
|
"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
|
// scope builds the correct auth scope for the registry client to authorize against
|
||||||
|
|
Loading…
Reference in New Issue