mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 10:25:42 +03:00
register drivers by default
Do not register mock_driver on release builds.
This commit is contained in:
@@ -1,12 +0,0 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
|
||||
// Each internal plugin has an init func which registers itself with the
|
||||
// plugin catalog. Since the plugin implementations are not imported by the
|
||||
// client or server they must be referenced here so plugin registration
|
||||
// occures.
|
||||
|
||||
// raw_exec driver
|
||||
_ "github.com/hashicorp/nomad/drivers/rawexec"
|
||||
)
|
||||
@@ -17,7 +17,6 @@ import (
|
||||
"github.com/hashicorp/nomad/plugins/base"
|
||||
"github.com/hashicorp/nomad/plugins/drivers"
|
||||
"github.com/hashicorp/nomad/plugins/drivers/utils"
|
||||
"github.com/hashicorp/nomad/plugins/shared/catalog"
|
||||
"github.com/hashicorp/nomad/plugins/shared/hclspec"
|
||||
"github.com/hashicorp/nomad/plugins/shared/loader"
|
||||
"golang.org/x/net/context"
|
||||
@@ -25,25 +24,27 @@ import (
|
||||
|
||||
// When the package is loaded the driver is registered as an internal plugin
|
||||
// with the plugin catalog
|
||||
func init() {
|
||||
catalog.RegisterDeferredConfig(loader.PluginID{
|
||||
var (
|
||||
PluginID = loader.PluginID{
|
||||
Name: pluginName,
|
||||
PluginType: base.PluginTypeDriver,
|
||||
}, &loader.InternalPluginConfig{
|
||||
}
|
||||
|
||||
PluginConfig = &loader.InternalPluginConfig{
|
||||
Config: map[string]interface{}{},
|
||||
Factory: func(l hclog.Logger) interface{} { return NewRawExecDriver(l) },
|
||||
},
|
||||
func(opts map[string]string) (map[string]interface{}, error) {
|
||||
conf := map[string]interface{}{}
|
||||
if v, err := strconv.ParseBool(opts["driver.raw_exec.enable"]); err == nil {
|
||||
conf["enabled"] = v
|
||||
}
|
||||
if v, err := strconv.ParseBool(opts["driver.raw_exec.no_cgroups"]); err == nil {
|
||||
conf["no_cgroups"] = v
|
||||
}
|
||||
return conf, nil
|
||||
},
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
func PluginLoader(opts map[string]string) (map[string]interface{}, error) {
|
||||
conf := map[string]interface{}{}
|
||||
if v, err := strconv.ParseBool(opts["driver.raw_exec.enable"]); err == nil {
|
||||
conf["enabled"] = v
|
||||
}
|
||||
if v, err := strconv.ParseBool(opts["driver.raw_exec.no_cgroups"]); err == nil {
|
||||
conf["no_cgroups"] = v
|
||||
}
|
||||
return conf, nil
|
||||
}
|
||||
|
||||
const (
|
||||
|
||||
10
plugins/shared/catalog/register.go
Normal file
10
plugins/shared/catalog/register.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package catalog
|
||||
|
||||
import "github.com/hashicorp/nomad/drivers/rawexec"
|
||||
|
||||
// This file is where all builtin plugins should be registered in the catalog.
|
||||
// Plugins with build restrictions should be placed in the appropriate
|
||||
// register_XXX.go file.
|
||||
func init() {
|
||||
RegisterDeferredConfig(rawexec.PluginID, rawexec.PluginConfig, rawexec.PluginLoader)
|
||||
}
|
||||
12
plugins/shared/catalog/register_testing.go
Normal file
12
plugins/shared/catalog/register_testing.go
Normal file
@@ -0,0 +1,12 @@
|
||||
// +build !release
|
||||
|
||||
package catalog
|
||||
|
||||
import "github.com/hashicorp/nomad/drivers/mock"
|
||||
|
||||
// Register the mock driver with the builtin driver plugin catalog. All builtin
|
||||
// plugins that are intended for production use should be registered in
|
||||
// register.go as this file is not built as part of a release.
|
||||
func init() {
|
||||
Register(mock.PluginID, mock.PluginConfig)
|
||||
}
|
||||
Reference in New Issue
Block a user