2018-02-05 21:05:59 +00:00
|
|
|
package plugingetter // import "github.com/docker/docker/pkg/plugingetter"
|
2016-10-04 17:52:18 +00:00
|
|
|
|
2017-10-20 19:39:47 +00:00
|
|
|
import (
|
2018-04-25 01:45:00 +00:00
|
|
|
"net"
|
|
|
|
"time"
|
|
|
|
|
2017-10-20 19:39:47 +00:00
|
|
|
"github.com/docker/docker/pkg/plugins"
|
|
|
|
)
|
2016-10-04 17:52:18 +00:00
|
|
|
|
|
|
|
const (
|
2016-12-20 02:18:43 +00:00
|
|
|
// Lookup doesn't update RefCount
|
|
|
|
Lookup = 0
|
|
|
|
// Acquire increments RefCount
|
|
|
|
Acquire = 1
|
|
|
|
// Release decrements RefCount
|
|
|
|
Release = -1
|
2016-10-04 17:52:18 +00:00
|
|
|
)
|
|
|
|
|
2016-12-19 06:45:48 +00:00
|
|
|
// CompatPlugin is an abstraction to handle both v2(new) and v1(legacy) plugins.
|
2016-10-04 17:52:18 +00:00
|
|
|
type CompatPlugin interface {
|
|
|
|
Name() string
|
2017-12-14 15:27:10 +00:00
|
|
|
ScopedPath(string) string
|
2016-10-04 17:52:18 +00:00
|
|
|
IsV1() bool
|
2018-05-30 19:00:42 +00:00
|
|
|
PluginWithV1Client
|
|
|
|
}
|
|
|
|
|
|
|
|
// PluginWithV1Client is a plugin that directly utilizes the v1/http plugin client
|
|
|
|
type PluginWithV1Client interface {
|
|
|
|
Client() *plugins.Client
|
2016-10-04 17:52:18 +00:00
|
|
|
}
|
|
|
|
|
2018-04-25 01:45:00 +00:00
|
|
|
// PluginAddr is a plugin that exposes the socket address for creating custom clients rather than the built-in `*plugins.Client`
|
|
|
|
type PluginAddr interface {
|
|
|
|
Addr() net.Addr
|
|
|
|
Timeout() time.Duration
|
|
|
|
Protocol() string
|
|
|
|
}
|
|
|
|
|
2016-11-30 21:02:45 +00:00
|
|
|
// CountedPlugin is a plugin which is reference counted.
|
|
|
|
type CountedPlugin interface {
|
|
|
|
Acquire()
|
|
|
|
Release()
|
|
|
|
CompatPlugin
|
|
|
|
}
|
|
|
|
|
2016-10-04 17:52:18 +00:00
|
|
|
// PluginGetter is the interface implemented by Store
|
|
|
|
type PluginGetter interface {
|
|
|
|
Get(name, capability string, mode int) (CompatPlugin, error)
|
|
|
|
GetAllByCap(capability string) ([]CompatPlugin, error)
|
2016-12-22 18:26:04 +00:00
|
|
|
GetAllManagedPluginsByCap(capability string) []CompatPlugin
|
2016-10-04 17:52:18 +00:00
|
|
|
Handle(capability string, callback func(string, *plugins.Client))
|
|
|
|
}
|