diff --git a/client/config/config.go b/client/config/config.go index 7a965da4e..241d65577 100644 --- a/client/config/config.go +++ b/client/config/config.go @@ -370,7 +370,9 @@ func (c *Config) ReadStringListToMapDefault(key, defaultValue string) map[string // NomadPluginConfig produces the NomadConfig struct which is sent to Nomad plugins func (c *Config) NomadPluginConfig() *base.NomadConfig { return &base.NomadConfig{ - ClientMinPort: c.ClientMinPort, - ClientMaxPort: c.ClientMaxPort, + Driver: &base.NomadDriverConfig{ + ClientMinPort: c.ClientMinPort, + ClientMaxPort: c.ClientMaxPort, + }, } } diff --git a/plugins/base/base.go b/plugins/base/base.go index 4aba71977..e51ae4adc 100644 --- a/plugins/base/base.go +++ b/plugins/base/base.go @@ -37,6 +37,11 @@ type PluginInfoResponse struct { // NomadConfig is the nomad client configuration sent to all plugins type NomadConfig struct { + Driver *NomadDriverConfig +} + +// NomadDriverConfig is the driver specific configuration for all driver plugins +type NomadDriverConfig struct { // ClientMaxPort is the upper range of the ports that the client uses for // communicating with plugin subsystems over loopback ClientMaxPort uint @@ -50,18 +55,31 @@ func (c *NomadConfig) toProto() *proto.NomadConfig { if c == nil { return nil } - return &proto.NomadConfig{ - ClientMaxPort: uint32(c.ClientMaxPort), - ClientMinPort: uint32(c.ClientMinPort), + + cfg := &proto.NomadConfig{} + if c.Driver != nil { + + cfg.Driver = &proto.NomadDriverConfig{ + ClientMaxPort: uint32(c.Driver.ClientMaxPort), + ClientMinPort: uint32(c.Driver.ClientMinPort), + } } + + return cfg } func nomadConfigFromProto(pb *proto.NomadConfig) *NomadConfig { if pb == nil { return nil } - return &NomadConfig{ - ClientMaxPort: uint(pb.ClientMaxPort), - ClientMinPort: uint(pb.ClientMinPort), + + cfg := &NomadConfig{} + if pb.Driver != nil { + cfg.Driver = &NomadDriverConfig{ + ClientMaxPort: uint(pb.Driver.ClientMaxPort), + ClientMinPort: uint(pb.Driver.ClientMinPort), + } } + + return cfg } diff --git a/plugins/base/plugin_test.go b/plugins/base/plugin_test.go index 345c6fcb4..f45b16f3f 100644 --- a/plugins/base/plugin_test.go +++ b/plugins/base/plugin_test.go @@ -112,6 +112,9 @@ func TestBasePlugin_SetConfig(t *testing.T) { var receivedData []byte mock := &MockPlugin{ + PluginInfoF: func() (*PluginInfoResponse, error) { + return &PluginInfoResponse{Type: PluginTypeDriver}, nil + }, ConfigSchemaF: func() (*hclspec.Spec, error) { return TestSpec, nil }, diff --git a/plugins/base/proto/base.pb.go b/plugins/base/proto/base.pb.go index 9ab0f4094..2c3616895 100644 --- a/plugins/base/proto/base.pb.go +++ b/plugins/base/proto/base.pb.go @@ -48,7 +48,7 @@ func (x PluginType) String() string { return proto.EnumName(PluginType_name, int32(x)) } func (PluginType) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_base_2cf49a455019f531, []int{0} + return fileDescriptor_base_9f9181869eb492df, []int{0} } // PluginInfoRequest is used to request the plugins basic information. @@ -62,7 +62,7 @@ func (m *PluginInfoRequest) Reset() { *m = PluginInfoRequest{} } func (m *PluginInfoRequest) String() string { return proto.CompactTextString(m) } func (*PluginInfoRequest) ProtoMessage() {} func (*PluginInfoRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_base_2cf49a455019f531, []int{0} + return fileDescriptor_base_9f9181869eb492df, []int{0} } func (m *PluginInfoRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_PluginInfoRequest.Unmarshal(m, b) @@ -104,7 +104,7 @@ func (m *PluginInfoResponse) Reset() { *m = PluginInfoResponse{} } func (m *PluginInfoResponse) String() string { return proto.CompactTextString(m) } func (*PluginInfoResponse) ProtoMessage() {} func (*PluginInfoResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_base_2cf49a455019f531, []int{1} + return fileDescriptor_base_9f9181869eb492df, []int{1} } func (m *PluginInfoResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_PluginInfoResponse.Unmarshal(m, b) @@ -163,7 +163,7 @@ func (m *ConfigSchemaRequest) Reset() { *m = ConfigSchemaRequest{} } func (m *ConfigSchemaRequest) String() string { return proto.CompactTextString(m) } func (*ConfigSchemaRequest) ProtoMessage() {} func (*ConfigSchemaRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_base_2cf49a455019f531, []int{2} + return fileDescriptor_base_9f9181869eb492df, []int{2} } func (m *ConfigSchemaRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ConfigSchemaRequest.Unmarshal(m, b) @@ -196,7 +196,7 @@ func (m *ConfigSchemaResponse) Reset() { *m = ConfigSchemaResponse{} } func (m *ConfigSchemaResponse) String() string { return proto.CompactTextString(m) } func (*ConfigSchemaResponse) ProtoMessage() {} func (*ConfigSchemaResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_base_2cf49a455019f531, []int{3} + return fileDescriptor_base_9f9181869eb492df, []int{3} } func (m *ConfigSchemaResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ConfigSchemaResponse.Unmarshal(m, b) @@ -238,7 +238,7 @@ func (m *SetConfigRequest) Reset() { *m = SetConfigRequest{} } func (m *SetConfigRequest) String() string { return proto.CompactTextString(m) } func (*SetConfigRequest) ProtoMessage() {} func (*SetConfigRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_base_2cf49a455019f531, []int{4} + return fileDescriptor_base_9f9181869eb492df, []int{4} } func (m *SetConfigRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SetConfigRequest.Unmarshal(m, b) @@ -274,22 +274,18 @@ func (m *SetConfigRequest) GetNomadConfig() *NomadConfig { // NomadConfig is the client configuration sent to all plugins type NomadConfig struct { - // ClientMaxPort is the upper range of the ports that the client uses for - // communicating with plugin subsystems over loopback - ClientMaxPort uint32 `protobuf:"varint,1,opt,name=ClientMaxPort,proto3" json:"ClientMaxPort,omitempty"` - // ClientMinPort is the lower range of the ports that the client uses for - // communicating with plugin subsystems over loopback - ClientMinPort uint32 `protobuf:"varint,2,opt,name=ClientMinPort,proto3" json:"ClientMinPort,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + // driver specific configuration sent to all plugins + Driver *NomadDriverConfig `protobuf:"bytes,1,opt,name=driver,proto3" json:"driver,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *NomadConfig) Reset() { *m = NomadConfig{} } func (m *NomadConfig) String() string { return proto.CompactTextString(m) } func (*NomadConfig) ProtoMessage() {} func (*NomadConfig) Descriptor() ([]byte, []int) { - return fileDescriptor_base_2cf49a455019f531, []int{5} + return fileDescriptor_base_9f9181869eb492df, []int{5} } func (m *NomadConfig) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_NomadConfig.Unmarshal(m, b) @@ -309,14 +305,59 @@ func (m *NomadConfig) XXX_DiscardUnknown() { var xxx_messageInfo_NomadConfig proto.InternalMessageInfo -func (m *NomadConfig) GetClientMaxPort() uint32 { +func (m *NomadConfig) GetDriver() *NomadDriverConfig { + if m != nil { + return m.Driver + } + return nil +} + +// NomadDriverConfig is the driver specific client configuration sent to all +// driver plugins +type NomadDriverConfig struct { + // ClientMaxPort is the upper range of the ports that the client uses for + // communicating with plugin subsystems over loopback + ClientMaxPort uint32 `protobuf:"varint,1,opt,name=ClientMaxPort,proto3" json:"ClientMaxPort,omitempty"` + // ClientMinPort is the lower range of the ports that the client uses for + // communicating with plugin subsystems over loopback + ClientMinPort uint32 `protobuf:"varint,2,opt,name=ClientMinPort,proto3" json:"ClientMinPort,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *NomadDriverConfig) Reset() { *m = NomadDriverConfig{} } +func (m *NomadDriverConfig) String() string { return proto.CompactTextString(m) } +func (*NomadDriverConfig) ProtoMessage() {} +func (*NomadDriverConfig) Descriptor() ([]byte, []int) { + return fileDescriptor_base_9f9181869eb492df, []int{6} +} +func (m *NomadDriverConfig) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_NomadDriverConfig.Unmarshal(m, b) +} +func (m *NomadDriverConfig) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_NomadDriverConfig.Marshal(b, m, deterministic) +} +func (dst *NomadDriverConfig) XXX_Merge(src proto.Message) { + xxx_messageInfo_NomadDriverConfig.Merge(dst, src) +} +func (m *NomadDriverConfig) XXX_Size() int { + return xxx_messageInfo_NomadDriverConfig.Size(m) +} +func (m *NomadDriverConfig) XXX_DiscardUnknown() { + xxx_messageInfo_NomadDriverConfig.DiscardUnknown(m) +} + +var xxx_messageInfo_NomadDriverConfig proto.InternalMessageInfo + +func (m *NomadDriverConfig) GetClientMaxPort() uint32 { if m != nil { return m.ClientMaxPort } return 0 } -func (m *NomadConfig) GetClientMinPort() uint32 { +func (m *NomadDriverConfig) GetClientMinPort() uint32 { if m != nil { return m.ClientMinPort } @@ -334,7 +375,7 @@ func (m *SetConfigResponse) Reset() { *m = SetConfigResponse{} } func (m *SetConfigResponse) String() string { return proto.CompactTextString(m) } func (*SetConfigResponse) ProtoMessage() {} func (*SetConfigResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_base_2cf49a455019f531, []int{6} + return fileDescriptor_base_9f9181869eb492df, []int{7} } func (m *SetConfigResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SetConfigResponse.Unmarshal(m, b) @@ -361,6 +402,7 @@ func init() { proto.RegisterType((*ConfigSchemaResponse)(nil), "hashicorp.nomad.plugins.base.proto.ConfigSchemaResponse") proto.RegisterType((*SetConfigRequest)(nil), "hashicorp.nomad.plugins.base.proto.SetConfigRequest") proto.RegisterType((*NomadConfig)(nil), "hashicorp.nomad.plugins.base.proto.NomadConfig") + proto.RegisterType((*NomadDriverConfig)(nil), "hashicorp.nomad.plugins.base.proto.NomadDriverConfig") proto.RegisterType((*SetConfigResponse)(nil), "hashicorp.nomad.plugins.base.proto.SetConfigResponse") proto.RegisterEnum("hashicorp.nomad.plugins.base.proto.PluginType", PluginType_name, PluginType_value) } @@ -509,39 +551,40 @@ var _BasePlugin_serviceDesc = grpc.ServiceDesc{ Metadata: "base.proto", } -func init() { proto.RegisterFile("base.proto", fileDescriptor_base_2cf49a455019f531) } +func init() { proto.RegisterFile("base.proto", fileDescriptor_base_9f9181869eb492df) } -var fileDescriptor_base_2cf49a455019f531 = []byte{ - // 484 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0xcf, 0x6f, 0x12, 0x41, - 0x14, 0xc7, 0xbb, 0x80, 0x6d, 0xfa, 0x80, 0x66, 0x9d, 0x6a, 0x42, 0x38, 0x35, 0x1b, 0x4d, 0x1a, - 0xd3, 0xcc, 0x46, 0xb4, 0xea, 0xb1, 0x82, 0x1c, 0x88, 0x11, 0x9b, 0x45, 0xf1, 0xc7, 0x85, 0x0c, - 0xdb, 0x29, 0x3b, 0x91, 0x9d, 0x19, 0x77, 0x16, 0x63, 0x4d, 0x3c, 0x79, 0xe6, 0x8f, 0xf2, 0x3f, - 0x33, 0xfb, 0x66, 0x17, 0x16, 0xa3, 0x29, 0x9c, 0x76, 0xf8, 0xbe, 0xcf, 0xfb, 0xc9, 0x17, 0x60, - 0xca, 0x0c, 0xa7, 0x3a, 0x51, 0xa9, 0x22, 0x5e, 0xc4, 0x4c, 0x24, 0x42, 0x95, 0x68, 0x2a, 0x55, - 0xcc, 0xae, 0xa8, 0x9e, 0x2f, 0x66, 0x42, 0x1a, 0xba, 0x66, 0xda, 0x17, 0x33, 0x91, 0x46, 0x8b, - 0x29, 0x0d, 0x55, 0xec, 0xaf, 0x70, 0x1f, 0x71, 0x3f, 0xc7, 0x7d, 0x13, 0xb1, 0x84, 0x5f, 0xf9, - 0x51, 0x38, 0x37, 0x9a, 0x87, 0xd9, 0x77, 0x92, 0x3d, 0x6c, 0x05, 0xef, 0x18, 0xee, 0x5e, 0x22, - 0x38, 0x90, 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00, 0xcd, 0xde, 0x5c, 0x70, 0x99, 0xbe, - 0x61, 0xdf, 0x2f, 0x55, 0x92, 0xe2, 0x20, 0xcd, 0x60, 0x53, 0x2c, 0x51, 0x42, 0x22, 0x55, 0xd9, - 0xa0, 0xac, 0x98, 0x99, 0xa6, 0xb4, 0xa9, 0xbd, 0xe0, 0xa3, 0xc7, 0x00, 0xeb, 0x7f, 0x9b, 0xd4, - 0xe1, 0xe0, 0xfd, 0xf0, 0xf5, 0xf0, 0xed, 0x87, 0xa1, 0xbb, 0x47, 0x00, 0xf6, 0x5f, 0x05, 0x83, - 0x71, 0x3f, 0x70, 0x2b, 0xf8, 0xee, 0x8f, 0x07, 0xbd, 0xbe, 0x5b, 0xed, 0x2c, 0xab, 0x00, 0x5d, - 0x66, 0xb8, 0xcd, 0x23, 0x3f, 0x8b, 0x0a, 0x99, 0xeb, 0xc8, 0xf9, 0xf6, 0xfe, 0x2a, 0x79, 0xb7, - 0xfd, 0x6c, 0xd7, 0x34, 0x3b, 0xbe, 0xb7, 0x47, 0x7e, 0x39, 0xd0, 0x28, 0x7b, 0x83, 0x3c, 0xdf, - 0xa6, 0xd4, 0x3f, 0x4c, 0xd6, 0x7e, 0xb1, 0x7b, 0xe2, 0x6a, 0x8a, 0x1f, 0x70, 0xb8, 0xba, 0x2d, - 0x79, 0xba, 0x4d, 0xa1, 0xbf, 0x4d, 0xd7, 0x3e, 0xdf, 0x31, 0xab, 0xe8, 0xdd, 0x3d, 0xf8, 0x7c, - 0x07, 0x83, 0xd3, 0x7d, 0xfc, 0x3c, 0xf9, 0x13, 0x00, 0x00, 0xff, 0xff, 0xfb, 0x28, 0x74, 0x29, - 0x90, 0x04, 0x00, 0x00, +var fileDescriptor_base_9f9181869eb492df = []byte{ + // 512 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0xdf, 0x6f, 0x12, 0x41, + 0x10, 0xc7, 0x7b, 0x80, 0x34, 0x1d, 0xa0, 0xa1, 0x5b, 0x4d, 0x08, 0x4f, 0xcd, 0x45, 0x93, 0xc6, + 0x34, 0x7b, 0x11, 0x45, 0x7d, 0xac, 0x50, 0x1e, 0x88, 0x29, 0x36, 0x87, 0xa2, 0x31, 0x26, 0x64, + 0x39, 0xb6, 0xdc, 0x46, 0x6e, 0x77, 0xbd, 0x3d, 0x1a, 0x6b, 0xe2, 0x93, 0xcf, 0xfd, 0xa3, 0xfc, + 0xcf, 0xcc, 0xed, 0xee, 0xc1, 0xe1, 0x8f, 0x78, 0x3c, 0xed, 0x32, 0xf3, 0x99, 0xef, 0xec, 0x0c, + 0xdf, 0x03, 0x98, 0x11, 0x45, 0xb1, 0x8c, 0x45, 0x22, 0x90, 0x1b, 0x12, 0x15, 0xb2, 0x40, 0xc4, + 0x12, 0x73, 0x11, 0x91, 0x39, 0x96, 0xcb, 0xd5, 0x82, 0x71, 0x85, 0x37, 0x4c, 0xfb, 0x7c, 0xc1, + 0x92, 0x70, 0x35, 0xc3, 0x81, 0x88, 0xbc, 0x35, 0xee, 0x69, 0xdc, 0xb3, 0xb8, 0xa7, 0x42, 0x12, + 0xd3, 0xb9, 0x17, 0x06, 0x4b, 0x25, 0x69, 0x90, 0x9e, 0xd3, 0xf4, 0x62, 0x14, 0xdc, 0x63, 0x38, + 0xba, 0xd2, 0xe0, 0x90, 0x5f, 0x0b, 0x9f, 0x7e, 0x59, 0x51, 0x95, 0xb8, 0x3f, 0x1d, 0x40, 0xf9, + 0xa8, 0x92, 0x82, 0x2b, 0x8a, 0x7a, 0x50, 0x49, 0x6e, 0x25, 0x6d, 0x39, 0x27, 0xce, 0xe9, 0x61, + 0x07, 0xe3, 0xff, 0x3f, 0x10, 0x1b, 0x95, 0xb7, 0xb7, 0x92, 0xfa, 0xba, 0x16, 0x9d, 0x01, 0x32, + 0xd8, 0x94, 0x48, 0x36, 0xbd, 0xa1, 0xb1, 0x62, 0x82, 0xb7, 0x4a,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 0x69, 0xfe, 0xa5, 0xc7, 0x4f, 0x00, 0x36, 0x8e, 0x42, 0x35, 0xd8, 0x7f, 0x37, 0x7a, + 0x3d, 0x7a, 0xf3, 0x7e, 0xd4, 0xdc, 0x43, 0x00, 0xd5, 0x0b, 0x7f, 0x38, 0x19, 0xf8, 0xcd, 0x92, + 0xbe, 0x0f, 0x26, 0xc3, 0xfe, 0xa0, 0x59, 0xee, 0xdc, 0x95, 0x01, 0x7a, 0x44, 0x51, 0x53, 0x87, + 0xbe, 0x67, 0x0a, 0xa9, 0xb3, 0x51, 0xb7, 0xb8, 0x87, 0x73, 0xdf, 0x47, 0xfb, 0xf9, 0xae, 0x65, + 0xe6, 0xf9, 0xee, 0x1e, 0xfa, 0xe1, 0x40, 0x3d, 0xef, 0x3f, 0xf4, 0xa2, 0x88, 0xd4, 0x5f, 0x8c, + 0xdc, 0x7e, 0xb9, 0x7b, 0xe1, 0xfa, 0x15, 0xdf, 0xe0, 0x60, 0xbd, 0x5b, 0xf4, 0xac, 0x88, 0xd0, + 0xef, 0xc6, 0x6e, 0x77, 0x77, 0xac, 0xca, 0x7a, 0xf7, 0xf6, 0x3f, 0xde, 0xd3, 0xc9, 0x59, 0x55, + 0x1f, 0x4f, 0x7f, 0x05, 0x00, 0x00, 0xff, 0xff, 0x20, 0xf9, 0x80, 0xf0, 0xf4, 0x04, 0x00, 0x00, } diff --git a/plugins/base/proto/base.proto b/plugins/base/proto/base.proto index 025d7945b..402e3b214 100644 --- a/plugins/base/proto/base.proto +++ b/plugins/base/proto/base.proto @@ -65,6 +65,13 @@ message SetConfigRequest { // NomadConfig is the client configuration sent to all plugins message NomadConfig { + // driver specific configuration sent to all plugins + NomadDriverConfig driver = 1; +} + +// NomadDriverConfig is the driver specific client configuration sent to all +// driver plugins +message NomadDriverConfig { // ClientMaxPort is the upper range of the ports that the client uses for // communicating with plugin subsystems over loopback uint32 ClientMaxPort = 1; diff --git a/plugins/base/server.go b/plugins/base/server.go index da34ba335..be20a38cc 100644 --- a/plugins/base/server.go +++ b/plugins/base/server.go @@ -55,8 +55,22 @@ func (b *basePluginServer) ConfigSchema(context.Context, *proto.ConfigSchemaRequ } func (b *basePluginServer) SetConfig(ctx context.Context, req *proto.SetConfigRequest) (*proto.SetConfigResponse, error) { + info, err := b.impl.PluginInfo() + if err != nil { + return nil, err + } + + // Client configuration is filtered based on plugin type + cfg := nomadConfigFromProto(req.GetNomadConfig()) + filteredCfg := new(NomadConfig) + + switch info.Type { + case PluginTypeDriver: + filteredCfg.Driver = cfg.Driver + } + // Set the config - if err := b.impl.SetConfig(req.GetMsgpackConfig(), nomadConfigFromProto(req.GetNomadConfig())); err != nil { + if err := b.impl.SetConfig(req.GetMsgpackConfig(), filteredCfg); err != nil { return nil, fmt.Errorf("SetConfig failed: %v", err) } diff --git a/plugins/drivers/utils/utils.go b/plugins/drivers/utils/utils.go index 4f5b64901..563930b32 100644 --- a/plugins/drivers/utils/utils.go +++ b/plugins/drivers/utils/utils.go @@ -26,7 +26,7 @@ func CgroupsMounted(node *structs.Node) bool { // CreateExecutor launches an executor plugin and returns an instance of the // Executor interface -func CreateExecutor(w io.Writer, level hclog.Level, nomadConfig *base.NomadConfig, +func CreateExecutor(w io.Writer, level hclog.Level, nomadConfig *base.NomadDriverConfig, executorConfig *dstructs.ExecutorConfig) (executor.Executor, *plugin.Client, error) { c, err := json.Marshal(executorConfig) @@ -43,6 +43,7 @@ func CreateExecutor(w io.Writer, level hclog.Level, nomadConfig *base.NomadConfi } config.HandshakeConfig = driver.HandshakeConfig config.Plugins = driver.GetPluginMap(w, level, executorConfig.FSIsolation) + config.MaxPort = nomadConfig.ClientMaxPort config.MinPort = nomadConfig.ClientMinPort diff --git a/plugins/shared/loader/loader_test.go b/plugins/shared/loader/loader_test.go index e57f0ff74..61c4be12a 100644 --- a/plugins/shared/loader/loader_test.go +++ b/plugins/shared/loader/loader_test.go @@ -699,7 +699,9 @@ func TestPluginLoader_Dispense_Internal(t *testing.T) { expKey := "set_config_worked" expNomadConfig := &base.NomadConfig{ - ClientMinPort: 100, + Driver: &base.NomadDriverConfig{ + ClientMinPort: 100, + }, } logger := testlog.HCLogger(t)