Skip to content

Commit b2f449e

Browse files
authored
Merge pull request #3 from samuelkarp/dynamic-count
dynamic: expose count of loaded plugins
2 parents e13be35 + f9de907 commit b2f449e

3 files changed

Lines changed: 10 additions & 8 deletions

File tree

dynamic/dynamic.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import "fmt"
2323
// Load is currently only implemented on non-static, non-gccgo builds for amd64
2424
// and arm64, and plugins must be built with the exact same version of Go as
2525
// containerd itself.
26-
func Load(path string) (err error) {
26+
func Load(path string) (loaded int, err error) {
2727
defer func() {
2828
if v := recover(); v != nil {
2929
rerr, ok := v.(error)

dynamic/dynamic_supported.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ import (
2727

2828
// loadPlugins loads all plugins for the OS and Arch
2929
// that containerd is built for inside the provided path
30-
func loadPlugins(path string) error {
30+
func loadPlugins(path string) (int, error) {
3131
abs, err := filepath.Abs(path)
3232
if err != nil {
33-
return err
33+
return 0, err
3434
}
3535
pattern := filepath.Join(abs, fmt.Sprintf(
3636
"*-%s-%s.%s",
@@ -40,14 +40,16 @@ func loadPlugins(path string) error {
4040
))
4141
libs, err := filepath.Glob(pattern)
4242
if err != nil {
43-
return err
43+
return 0, err
4444
}
45+
loaded := 0
4546
for _, lib := range libs {
4647
if _, err := plugin.Open(lib); err != nil {
47-
return err
48+
return loaded, err
4849
}
50+
loaded++
4951
}
50-
return nil
52+
return loaded, nil
5153
}
5254

5355
// getLibExt returns a platform specific lib extension for

dynamic/dynamic_unsupported.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ package dynamic
2323
// - with gccgo: gccgo has no plugin support golang/go#36403
2424
// - on static builds; https://github.com/containerd/containerd/commit/0d682e24a1ba8e93e5e54a73d64f7d256f87492f
2525
// - on architectures other than amd64 and arm64 (other architectures need to be tested)
26-
func loadPlugins(path string) error {
27-
return nil
26+
func loadPlugins(path string) (int, error) {
27+
return 0, nil
2828
}

0 commit comments

Comments
 (0)