From 2285942384971cdc062af463b7b9e12708640f98 Mon Sep 17 00:00:00 2001 From: Martynas Pumputis Date: Fri, 12 May 2017 13:13:35 +0300 Subject: [PATCH] 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. --- prog/weaveutil/plugin_network.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/prog/weaveutil/plugin_network.go b/prog/weaveutil/plugin_network.go index 064ed0fe..451e2bf9 100644 --- a/prog/weaveutil/plugin_network.go +++ b/prog/weaveutil/plugin_network.go @@ -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) {