Merge pull request #18810 from runcom/pkg-authz-fixes
pkg: authorization: do not register the same plugin
This commit is contained in:
commit
4fef057438
3 changed files with 9 additions and 5 deletions
|
@ -17,9 +17,14 @@ type Plugin interface {
|
||||||
|
|
||||||
// NewPlugins constructs and initialize the authorization plugins based on plugin names
|
// NewPlugins constructs and initialize the authorization plugins based on plugin names
|
||||||
func NewPlugins(names []string) []Plugin {
|
func NewPlugins(names []string) []Plugin {
|
||||||
plugins := make([]Plugin, len(names))
|
plugins := []Plugin{}
|
||||||
for i, name := range names {
|
pluginsMap := make(map[string]struct{})
|
||||||
plugins[i] = newAuthorizationPlugin(name)
|
for _, name := range names {
|
||||||
|
if _, ok := pluginsMap[name]; ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
pluginsMap[name] = struct{}{}
|
||||||
|
plugins = append(plugins, newAuthorizationPlugin(name))
|
||||||
}
|
}
|
||||||
return plugins
|
return plugins
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ import (
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// ErrNotFound plugin not found
|
// ErrNotFound plugin not found
|
||||||
ErrNotFound = errors.New("Plugin not found")
|
ErrNotFound = errors.New("plugin not found")
|
||||||
socketsPath = "/run/docker/plugins"
|
socketsPath = "/run/docker/plugins"
|
||||||
specsPaths = []string{"/etc/docker/plugins", "/usr/lib/docker/plugins"}
|
specsPaths = []string{"/etc/docker/plugins", "/usr/lib/docker/plugins"}
|
||||||
)
|
)
|
||||||
|
|
|
@ -96,7 +96,6 @@ func (p *Plugin) activateWithLock() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Debugf("%s's manifest: %v", p.Name, m)
|
|
||||||
p.Manifest = m
|
p.Manifest = m
|
||||||
|
|
||||||
for _, iface := range m.Implements {
|
for _, iface := range m.Implements {
|
||||||
|
|
Loading…
Reference in a new issue