Move dynamic plugins to a subpackage
Signed-off-by: Derek McGowan <derek@mcg.dev>
This commit is contained in:
parent
7b2a918213
commit
71f8b4357e
37
plugin/dynamic/dynamic.go
Normal file
37
plugin/dynamic/dynamic.go
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
Copyright The containerd Authors.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package dynamic
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
// Load loads all plugins at the provided path into containerd.
|
||||||
|
//
|
||||||
|
// Load is currently only implemented on non-static, non-gccgo builds for amd64
|
||||||
|
// and arm64, and plugins must be built with the exact same version of Go as
|
||||||
|
// containerd itself.
|
||||||
|
func Load(path string) (err error) {
|
||||||
|
defer func() {
|
||||||
|
if v := recover(); v != nil {
|
||||||
|
rerr, ok := v.(error)
|
||||||
|
if !ok {
|
||||||
|
rerr = fmt.Errorf("%s", v)
|
||||||
|
}
|
||||||
|
err = rerr
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
return loadPlugins(path)
|
||||||
|
}
|
@ -16,7 +16,7 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package plugin
|
package dynamic
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
@ -16,7 +16,7 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package plugin
|
package dynamic
|
||||||
|
|
||||||
// loadPlugins is not supported;
|
// loadPlugins is not supported;
|
||||||
//
|
//
|
@ -96,24 +96,6 @@ func (r *Registration) URI() string {
|
|||||||
return r.Type.String() + "." + r.ID
|
return r.Type.String() + "." + r.ID
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load loads all plugins at the provided path into containerd.
|
|
||||||
//
|
|
||||||
// Load is currently only implemented on non-static, non-gccgo builds for amd64
|
|
||||||
// and arm64, and plugins must be built with the exact same version of Go as
|
|
||||||
// containerd itself.
|
|
||||||
func Load(path string) (err error) {
|
|
||||||
defer func() {
|
|
||||||
if v := recover(); v != nil {
|
|
||||||
rerr, ok := v.(error)
|
|
||||||
if !ok {
|
|
||||||
rerr = fmt.Errorf("%s", v)
|
|
||||||
}
|
|
||||||
err = rerr
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
return loadPlugins(path)
|
|
||||||
}
|
|
||||||
|
|
||||||
// DisableFilter filters out disabled plugins
|
// DisableFilter filters out disabled plugins
|
||||||
type DisableFilter func(r *Registration) bool
|
type DisableFilter func(r *Registration) bool
|
||||||
|
|
||||||
|
@ -46,6 +46,7 @@ import (
|
|||||||
"github.com/containerd/containerd/pkg/timeout"
|
"github.com/containerd/containerd/pkg/timeout"
|
||||||
"github.com/containerd/containerd/platforms"
|
"github.com/containerd/containerd/platforms"
|
||||||
"github.com/containerd/containerd/plugin"
|
"github.com/containerd/containerd/plugin"
|
||||||
|
"github.com/containerd/containerd/plugin/dynamic"
|
||||||
"github.com/containerd/containerd/plugin/registry"
|
"github.com/containerd/containerd/plugin/registry"
|
||||||
"github.com/containerd/containerd/plugins"
|
"github.com/containerd/containerd/plugins"
|
||||||
srvconfig "github.com/containerd/containerd/services/server/config"
|
srvconfig "github.com/containerd/containerd/services/server/config"
|
||||||
@ -434,7 +435,7 @@ func LoadPlugins(ctx context.Context, config *srvconfig.Config) ([]plugin.Regist
|
|||||||
if path == "" {
|
if path == "" {
|
||||||
path = filepath.Join(config.Root, "plugins")
|
path = filepath.Join(config.Root, "plugins")
|
||||||
}
|
}
|
||||||
if err := plugin.Load(path); err != nil {
|
if err := dynamic.Load(path); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
// load additional plugins that don't automatically register themselves
|
// load additional plugins that don't automatically register themselves
|
||||||
|
Loading…
Reference in New Issue
Block a user