Add better detection for plugin-v2 (net-plugin)
The problem is that the plugin name is prefixed with a registry name. So, if the plugin is fetched from Docker Store, its name will be "store/weaveworks/net-plugin". The detection function does an exact match on "weaveworks/net-plugin", so in the Docker Store case, the presence of the plugin cannot be detected.
This commit is contained in:
1 parent
70929cec57
commit
2285942384
1 file changed
+8
-4
@@ -4,6 +4,7 @@ package main
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/docker/docker/client"
|
||||
docker "github.com/fsouza/go-dockerclient"
|
||||
@@ -56,16 +57,19 @@ func isDockerPluginEnabled(args []string) error {
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
p, _, err := c.PluginInspectWithRaw(ctx, pluginName)
|
||||
|
||||
plugins, err := c.PluginList(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if !p.Enabled {
|
||||
return fmt.Errorf("plugin %q is disabled", pluginName)
|
||||
for _, p := range plugins {
|
||||
if p.Enabled && strings.Contains(p.Name, pluginName) {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
return fmt.Errorf("plugin %q not found", pluginName)
|
||||
}
|
||||
|
||||
func newDockerClient() (*docker.Client, error) {
|
||||
|
||||
Reference in new issue
Block a user