diff --git a/pkg/plugins/discovery_test.go b/pkg/plugins/discovery_test.go index 60440443cc..e5c3709cea 100644 --- a/pkg/plugins/discovery_test.go +++ b/pkg/plugins/discovery_test.go @@ -43,10 +43,10 @@ func TestFileSpecPlugin(t *testing.T) { } for _, c := range cases { - if err := os.MkdirAll(filepath.Dir(c.path), 0755); err != nil { + if err := os.MkdirAll(filepath.Dir(c.path), 0o755); err != nil { t.Fatal(err) } - if err := os.WriteFile(c.path, []byte(c.addr), 0644); err != nil { + if err := os.WriteFile(c.path, []byte(c.addr), 0o644); err != nil { t.Fatal(err) } @@ -88,7 +88,7 @@ func TestFileJSONSpecPlugin(t *testing.T) { } }` - if err := os.WriteFile(p, []byte(spec), 0644); err != nil { + if err := os.WriteFile(p, []byte(spec), 0o644); err != nil { t.Fatal(err) } @@ -128,7 +128,7 @@ func TestFileJSONSpecPluginWithoutTLSConfig(t *testing.T) { "Addr": "https://example.com/docker/plugin" }` - if err := os.WriteFile(p, []byte(spec), 0644); err != nil { + if err := os.WriteFile(p, []byte(spec), 0o644); err != nil { t.Fatal(err) } diff --git a/pkg/plugins/discovery_unix_test.go b/pkg/plugins/discovery_unix_test.go index da019d734d..ec9dc95866 100644 --- a/pkg/plugins/discovery_unix_test.go +++ b/pkg/plugins/discovery_unix_test.go @@ -24,7 +24,7 @@ func TestLocalSocket(t *testing.T) { } for _, c := range cases { - if err := os.MkdirAll(filepath.Dir(c), 0755); err != nil { + if err := os.MkdirAll(filepath.Dir(c), 0o755); err != nil { t.Fatal(err) } @@ -77,12 +77,12 @@ func TestScan(t *testing.T) { addr := "unix://var/lib/docker/plugins/echo.sock" name := "echo" - err = os.MkdirAll(filepath.Dir(path), 0755) + err = os.MkdirAll(filepath.Dir(path), 0o755) if err != nil { t.Fatal(err) } - err = os.WriteFile(path, []byte(addr), 0644) + err = os.WriteFile(path, []byte(addr), 0o644) if err != nil { t.Fatal(err) } @@ -110,7 +110,7 @@ func TestScanNotPlugins(t *testing.T) { // `Scan()` uses to find plugins to the returned `tmpdir` notPlugin := filepath.Join(tmpdir, "not-a-plugin") - if err := os.MkdirAll(notPlugin, 0700); err != nil { + if err := os.MkdirAll(notPlugin, 0o700); err != nil { t.Fatal(err) } diff --git a/pkg/plugins/plugin_test.go b/pkg/plugins/plugin_test.go index c4df5d455c..a59552d94f 100644 --- a/pkg/plugins/plugin_test.go +++ b/pkg/plugins/plugin_test.go @@ -132,7 +132,7 @@ func TestGetAll(t *testing.T) { "Addr": "https://example.com/docker/plugin" }` - if err := os.WriteFile(p, []byte(spec), 0644); err != nil { + if err := os.WriteFile(p, []byte(spec), 0o644); err != nil { t.Fatal(err) } diff --git a/pkg/plugins/pluginrpc-gen/main.go b/pkg/plugins/pluginrpc-gen/main.go index cd39588340..06a1e4e9e2 100644 --- a/pkg/plugins/pluginrpc-gen/main.go +++ b/pkg/plugins/pluginrpc-gen/main.go @@ -22,6 +22,7 @@ func (s stringSet) Set(value string) error { s.values[value] = struct{}{} return nil } + func (s stringSet) GetValues() map[string]struct{} { return s.values } @@ -67,7 +68,7 @@ func main() { pkg, err := Parse(*inputFile, *typeName) errorOut(fmt.Sprintf("error parsing requested type %s", *typeName), err) - var analysis = struct { + analysis := struct { InterfaceType string RPCName string BuildTags map[string]struct{} @@ -78,7 +79,7 @@ func main() { errorOut("parser error", generatedTempl.Execute(&buf, analysis)) src, err := format.Source(buf.Bytes()) errorOut("error formatting generated source:\n"+buf.String(), err) - errorOut("error writing file", os.WriteFile(*outputFile, src, 0644)) + errorOut("error writing file", os.WriteFile(*outputFile, src, 0o644)) } func toLower(s string) string { diff --git a/pkg/plugins/plugins.go b/pkg/plugins/plugins.go index cc1f55b90f..91a0998ba4 100644 --- a/pkg/plugins/plugins.go +++ b/pkg/plugins/plugins.go @@ -36,10 +36,8 @@ import ( // ProtocolSchemeHTTPV1 is the name of the protocol used for interacting with plugins using this package. const ProtocolSchemeHTTPV1 = "moby.plugins.http/v1" -var ( - // ErrNotImplements is returned if the plugin does not implement the requested driver. - ErrNotImplements = errors.New("Plugin does not implement the requested driver") -) +// ErrNotImplements is returned if the plugin does not implement the requested driver. +var ErrNotImplements = errors.New("Plugin does not implement the requested driver") type plugins struct { sync.Mutex