aboutsummaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorSebastiaan van Stijn <thaJeztah@users.noreply.github.com>2022-04-21 20:49:56 +0200
committerGitHub <noreply@github.com>2022-04-21 20:49:56 +0200
commita189651b4c772881ba87eec181312cd8bc20ec2e (patch)
tree2c49558766fef43b71f6d635f5a467bd11a2ab30 /plugin
parentccb691a4274e7b5a3ebba6f32e5baa232aac1052 (diff)
parentf9f549cbe445177c1f0f4b13173e3b049674a3a1 (diff)
Merge pull request #43358 from thaJeztah/plugin_EndpointResolver
plugin: add EndpointResolver interface
Diffstat (limited to 'plugin')
-rw-r--r--plugin/manager.go25
-rw-r--r--plugin/registry.go9
2 files changed, 9 insertions, 25 deletions
diff --git a/plugin/manager.go b/plugin/manager.go
index f126cd7a03..3296ba4e77 100644
--- a/plugin/manager.go
+++ b/plugin/manager.go
@@ -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,
}
diff --git a/plugin/registry.go b/plugin/registry.go
index ad2a6b7138..e7643b6aaf 100644
--- a/plugin/registry.go
+++ b/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