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

drvregistry to allow overriding plugin

drvRegistry isnt aware if a plugin is v1 or v2. Plugin-v2 provides a way
for user to disable and remove plugins. But unfortunately, there isnt
any api to advertise the removal to drvRegistry. Hence there is no way
to handle "docker plugin rm" of installed plugin. In order to support
the case of "docker plugin install x" followed by "docker plugin rm x"
followed by reinstalling of plugin x "docker plugin install x",
drvRegistry must allow overriding any existing plugin with the same
name. The protection in plugin infra will prevent willful override of
existing plugin.

Signed-off-by: Madhu Venugopal <madhu@docker.com>
This commit is contained in:
Madhu Venugopal 2016-12-18 20:01:09 -08:00
parent 1b28c5e01d
commit 92efad001c
2 changed files with 8 additions and 4 deletions

View file

@ -164,10 +164,10 @@ func (r *DrvRegistry) RegisterDriver(ntype string, driver driverapi.Driver, capa
}
r.Lock()
_, ok := r.drivers[ntype]
dd, ok := r.drivers[ntype]
r.Unlock()
if ok {
if ok && dd.driver.IsBuiltIn() {
return driverapi.ErrActiveRegistration(ntype)
}
@ -192,9 +192,9 @@ func (r *DrvRegistry) registerIpamDriver(name string, driver ipamapi.Ipam, caps
}
r.Lock()
_, ok := r.ipamDrivers[name]
dd, ok := r.ipamDrivers[name]
r.Unlock()
if ok {
if ok && dd.driver.IsBuiltIn() {
return types.ForbiddenErrorf("ipam driver %q already registered", name)
}

View file

@ -68,6 +68,10 @@ func (m *mockDriver) Type() string {
return mockDriverName
}
func (m *mockDriver) IsBuiltIn() bool {
return true
}
func (m *mockDriver) ProgramExternalConnectivity(nid, eid string, options map[string]interface{}) error {
return nil
}