Merge pull request #2950 from weaveworks/issues/better-plugin-v2-detection
Better plugin-v2 detection
This commit is contained in:
commit
9740478151
2 files changed
+12
-7
No files matched your search
@@ -4,6 +4,7 @@ package main
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/docker/docker/client"
|
||||
docker "github.com/fsouza/go-dockerclient"
|
||||
@@ -56,16 +57,20 @@ 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) {
|
||||
fmt.Println(p.Name)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
return fmt.Errorf("plugin %q not found", pluginName)
|
||||
}
|
||||
|
||||
func newDockerClient() (*docker.Client, error) {
|
||||
|
||||
Reference in new issue
Block a user