Skip to content

Commit

Permalink
make testable
Browse files Browse the repository at this point in the history
  • Loading branch information
letmutx committed May 21, 2022
1 parent 080b8ca commit 02b22e1
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions device.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

log "github.com/hashicorp/go-hclog"
"github.com/hashicorp/nomad/devices/gpu/nvidia"
"github.com/hashicorp/nomad/helper/pluginutils/loader"
"github.com/hashicorp/nomad/plugins/base"
"github.com/hashicorp/nomad/plugins/device"
"github.com/hashicorp/nomad/plugins/shared/hclspec"
Expand Down Expand Up @@ -41,10 +40,6 @@ var (
Name: pluginName,
}

PluginConfig = &loader.InternalPluginConfig{
Factory: func(ctx context.Context, l log.Logger) interface{} { return NewPlugin(ctx, l) },
}

configSpec = hclspec.NewObject(map[string]*hclspec.Spec{
"enabled": hclspec.NewDefault(
hclspec.NewAttr("enabled", "bool", false),
Expand Down Expand Up @@ -85,9 +80,13 @@ type NvidiaVgpuPlugin struct {
//
// Plugin configuration isn't available yet, so there will typically be
// a limit to the initialization that can be performed at this point.
func NewPlugin(ctx context.Context, log log.Logger) *NvidiaVgpuPlugin {
func NewPlugin(ctx context.Context, log log.Logger) interface{} {
return NewPluginWithNvidiaPlugin(ctx, log, nvidia.NewNvidiaDevice(ctx, log))
}

func NewPluginWithNvidiaPlugin(ctx context.Context, log log.Logger, nv NvidiaDevicePlugin) *NvidiaVgpuPlugin {
return &NvidiaVgpuPlugin{
NvidiaDevicePlugin: nvidia.NewNvidiaDevice(ctx, log),
NvidiaDevicePlugin: nv,
devices: map[string]struct{}{},
log: log,
}
Expand Down

0 comments on commit 02b22e1

Please sign in to comment.