Clean up plugin lookup usage
This commit is contained in:
parent
db249d58ac
commit
c441fac0db
|
@ -17,12 +17,12 @@ func GuestCapabilities(pluginName, pluginType *C.char) *C.char {
|
||||||
r.Error = err
|
r.Error = err
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
}
|
}
|
||||||
p, ok := i.(*plugin.RemoteGuestCapabilities)
|
p, ok := i.(plugin.GuestCapabilities)
|
||||||
if !ok {
|
if !ok {
|
||||||
r.Error = errors.New("failed to load requested plugin")
|
r.Error = errors.New("failed to load requested plugin")
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
}
|
}
|
||||||
r.Result, r.Error = p.GuestCapabilities.GuestCapabilities()
|
r.Result, r.Error = p.GuestCapabilities()
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ func GuestCapability(pluginName, pluginType, cname, cplatform, cargs, cmachine *
|
||||||
r.Error = err
|
r.Error = err
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
}
|
}
|
||||||
p, ok := i.(*plugin.RemoteGuestCapabilities)
|
p, ok := i.(plugin.GuestCapabilities)
|
||||||
if !ok {
|
if !ok {
|
||||||
r.Error = errors.New("Failed to load requested plugin")
|
r.Error = errors.New("Failed to load requested plugin")
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
|
@ -53,7 +53,7 @@ func GuestCapability(pluginName, pluginType, cname, cplatform, cargs, cmachine *
|
||||||
cap := &vagrant.SystemCapability{
|
cap := &vagrant.SystemCapability{
|
||||||
Name: to_gs(cname),
|
Name: to_gs(cname),
|
||||||
Platform: to_gs(cplatform)}
|
Platform: to_gs(cplatform)}
|
||||||
r.Result, r.Error = p.GuestCapabilities.GuestCapability(cap, args, machine)
|
r.Result, r.Error = p.GuestCapability(cap, args, machine)
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,13 +65,13 @@ func HostCapabilities(pluginName, pluginType *C.char) *C.char {
|
||||||
r.Error = err
|
r.Error = err
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
}
|
}
|
||||||
p, ok := i.(*plugin.RemoteHostCapabilities)
|
p, ok := i.(plugin.HostCapabilities)
|
||||||
if !ok {
|
if !ok {
|
||||||
r.Error = errors.New("Failed to load requested plugin")
|
r.Error = errors.New("Failed to load requested plugin")
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
}
|
}
|
||||||
|
|
||||||
r.Result, r.Error = p.HostCapabilities.HostCapabilities()
|
r.Result, r.Error = p.HostCapabilities()
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ func HostCapability(pluginName, pluginType, cname, cplatform, cargs, cenv *C.cha
|
||||||
r.Error = err
|
r.Error = err
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
}
|
}
|
||||||
p, ok := i.(*plugin.RemoteHostCapabilities)
|
p, ok := i.(plugin.HostCapabilities)
|
||||||
if !ok {
|
if !ok {
|
||||||
r.Error = errors.New("Failed to load requested plugin")
|
r.Error = errors.New("Failed to load requested plugin")
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
|
@ -103,7 +103,7 @@ func HostCapability(pluginName, pluginType, cname, cplatform, cargs, cenv *C.cha
|
||||||
cap := &vagrant.SystemCapability{
|
cap := &vagrant.SystemCapability{
|
||||||
Name: to_gs(cname),
|
Name: to_gs(cname),
|
||||||
Platform: to_gs(cplatform)}
|
Platform: to_gs(cplatform)}
|
||||||
r.Result, r.Error = p.HostCapabilities.HostCapability(cap, args, env)
|
r.Result, r.Error = p.HostCapability(cap, args, env)
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,13 +115,13 @@ func ProviderCapabilities(pluginName, pluginType *C.char) *C.char {
|
||||||
r.Error = err
|
r.Error = err
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
}
|
}
|
||||||
p, ok := i.(*plugin.RemoteProviderCapabilities)
|
p, ok := i.(plugin.ProviderCapabilities)
|
||||||
if !ok {
|
if !ok {
|
||||||
r.Error = errors.New("Failed to load requested plugin")
|
r.Error = errors.New("Failed to load requested plugin")
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
}
|
}
|
||||||
|
|
||||||
r.Result, r.Error = p.ProviderCapabilities.ProviderCapabilities()
|
r.Result, r.Error = p.ProviderCapabilities()
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ func ProviderCapability(pluginName, pluginType, cname, cprovider, cargs, cmach *
|
||||||
r.Error = err
|
r.Error = err
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
}
|
}
|
||||||
p, ok := i.(*plugin.RemoteProviderCapabilities)
|
p, ok := i.(plugin.ProviderCapabilities)
|
||||||
if !ok {
|
if !ok {
|
||||||
r.Error = errors.New("Failed to load requested plugin")
|
r.Error = errors.New("Failed to load requested plugin")
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
|
@ -153,6 +153,6 @@ func ProviderCapability(pluginName, pluginType, cname, cprovider, cargs, cmach *
|
||||||
cap := &vagrant.ProviderCapability{
|
cap := &vagrant.ProviderCapability{
|
||||||
Name: to_gs(cname),
|
Name: to_gs(cname),
|
||||||
Provider: to_gs(cprovider)}
|
Provider: to_gs(cprovider)}
|
||||||
r.Result, r.Error = p.ProviderCapabilities.ProviderCapability(cap, args, m)
|
r.Result, r.Error = p.ProviderCapability(cap, args, m)
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,11 +23,9 @@ func TestCapabilities_GuestCapabilities(t *testing.T) {
|
||||||
t.Fatalf("bad %#v", raw)
|
t.Fatalf("bad %#v", raw)
|
||||||
}
|
}
|
||||||
|
|
||||||
p := &vplugin.RemoteGuestCapabilities{
|
|
||||||
GuestCapabilities: impl}
|
|
||||||
Plugins = vplugin.VagrantPluginInit()
|
Plugins = vplugin.VagrantPluginInit()
|
||||||
Plugins.PluginLookup = func(_, _ string) (r interface{}, err error) {
|
Plugins.PluginLookup = func(_, _ string) (r interface{}, err error) {
|
||||||
r = p
|
r = impl
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,11 +67,9 @@ func TestCapabilities_GuestCapability(t *testing.T) {
|
||||||
t.Fatalf("bad %#v", raw)
|
t.Fatalf("bad %#v", raw)
|
||||||
}
|
}
|
||||||
|
|
||||||
p := &vplugin.RemoteGuestCapabilities{
|
|
||||||
GuestCapabilities: impl}
|
|
||||||
Plugins = vplugin.VagrantPluginInit()
|
Plugins = vplugin.VagrantPluginInit()
|
||||||
Plugins.PluginLookup = func(_, _ string) (r interface{}, err error) {
|
Plugins.PluginLookup = func(_, _ string) (r interface{}, err error) {
|
||||||
r = p
|
r = impl
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,11 +112,9 @@ func TestCapabilities_GuestCapability_noargs(t *testing.T) {
|
||||||
t.Fatalf("bad %#v", raw)
|
t.Fatalf("bad %#v", raw)
|
||||||
}
|
}
|
||||||
|
|
||||||
p := &vplugin.RemoteGuestCapabilities{
|
|
||||||
GuestCapabilities: impl}
|
|
||||||
Plugins = vplugin.VagrantPluginInit()
|
Plugins = vplugin.VagrantPluginInit()
|
||||||
Plugins.PluginLookup = func(_, _ string) (r interface{}, err error) {
|
Plugins.PluginLookup = func(_, _ string) (r interface{}, err error) {
|
||||||
r = p
|
r = impl
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,11 +152,9 @@ func TestCapabilities_HostCapabilities(t *testing.T) {
|
||||||
t.Fatalf("bad %#v", raw)
|
t.Fatalf("bad %#v", raw)
|
||||||
}
|
}
|
||||||
|
|
||||||
p := &vplugin.RemoteHostCapabilities{
|
|
||||||
HostCapabilities: impl}
|
|
||||||
Plugins = vplugin.VagrantPluginInit()
|
Plugins = vplugin.VagrantPluginInit()
|
||||||
Plugins.PluginLookup = func(_, _ string) (r interface{}, err error) {
|
Plugins.PluginLookup = func(_, _ string) (r interface{}, err error) {
|
||||||
r = p
|
r = impl
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,11 +196,9 @@ func TestCapabilities_HostCapability(t *testing.T) {
|
||||||
t.Fatalf("bad %#v", raw)
|
t.Fatalf("bad %#v", raw)
|
||||||
}
|
}
|
||||||
|
|
||||||
p := &vplugin.RemoteHostCapabilities{
|
|
||||||
HostCapabilities: impl}
|
|
||||||
Plugins = vplugin.VagrantPluginInit()
|
Plugins = vplugin.VagrantPluginInit()
|
||||||
Plugins.PluginLookup = func(_, _ string) (r interface{}, err error) {
|
Plugins.PluginLookup = func(_, _ string) (r interface{}, err error) {
|
||||||
r = p
|
r = impl
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,11 +241,9 @@ func TestCapabilities_HostCapability_noargs(t *testing.T) {
|
||||||
t.Fatalf("bad %#v", raw)
|
t.Fatalf("bad %#v", raw)
|
||||||
}
|
}
|
||||||
|
|
||||||
p := &vplugin.RemoteHostCapabilities{
|
|
||||||
HostCapabilities: impl}
|
|
||||||
Plugins = vplugin.VagrantPluginInit()
|
Plugins = vplugin.VagrantPluginInit()
|
||||||
Plugins.PluginLookup = func(_, _ string) (r interface{}, err error) {
|
Plugins.PluginLookup = func(_, _ string) (r interface{}, err error) {
|
||||||
r = p
|
r = impl
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -293,11 +281,9 @@ func TestCapabilities_ProviderCapabilities(t *testing.T) {
|
||||||
t.Fatalf("bad %#v", raw)
|
t.Fatalf("bad %#v", raw)
|
||||||
}
|
}
|
||||||
|
|
||||||
p := &vplugin.RemoteProviderCapabilities{
|
|
||||||
ProviderCapabilities: impl}
|
|
||||||
Plugins = vplugin.VagrantPluginInit()
|
Plugins = vplugin.VagrantPluginInit()
|
||||||
Plugins.PluginLookup = func(_, _ string) (r interface{}, err error) {
|
Plugins.PluginLookup = func(_, _ string) (r interface{}, err error) {
|
||||||
r = p
|
r = impl
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,11 +325,9 @@ func TestCapabilities_ProviderCapability(t *testing.T) {
|
||||||
t.Fatalf("bad %#v", raw)
|
t.Fatalf("bad %#v", raw)
|
||||||
}
|
}
|
||||||
|
|
||||||
p := &vplugin.RemoteProviderCapabilities{
|
|
||||||
ProviderCapabilities: impl}
|
|
||||||
Plugins = vplugin.VagrantPluginInit()
|
Plugins = vplugin.VagrantPluginInit()
|
||||||
Plugins.PluginLookup = func(_, _ string) (r interface{}, err error) {
|
Plugins.PluginLookup = func(_, _ string) (r interface{}, err error) {
|
||||||
r = p
|
r = impl
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -386,11 +370,9 @@ func TestCapabilities_ProviderCapability_noargs(t *testing.T) {
|
||||||
t.Fatalf("bad %#v", raw)
|
t.Fatalf("bad %#v", raw)
|
||||||
}
|
}
|
||||||
|
|
||||||
p := &vplugin.RemoteProviderCapabilities{
|
|
||||||
ProviderCapabilities: impl}
|
|
||||||
Plugins = vplugin.VagrantPluginInit()
|
Plugins = vplugin.VagrantPluginInit()
|
||||||
Plugins.PluginLookup = func(_, _ string) (r interface{}, err error) {
|
Plugins.PluginLookup = func(_, _ string) (r interface{}, err error) {
|
||||||
r = p
|
r = impl
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ func ConfigLoad(pluginName, pluginType, data *C.char) *C.char {
|
||||||
r.Error = err
|
r.Error = err
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
}
|
}
|
||||||
p, ok := i.(*plugin.RemoteConfig)
|
p, ok := i.(plugin.Config)
|
||||||
if !ok {
|
if !ok {
|
||||||
r.Error = errors.New("failed to load requested plugin")
|
r.Error = errors.New("failed to load requested plugin")
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
|
@ -27,7 +27,7 @@ func ConfigLoad(pluginName, pluginType, data *C.char) *C.char {
|
||||||
if r.Error != nil {
|
if r.Error != nil {
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
}
|
}
|
||||||
r.Result, r.Error = p.Config.ConfigLoad(cdata)
|
r.Result, r.Error = p.ConfigLoad(cdata)
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,12 +39,12 @@ func ConfigAttributes(pluginName, pluginType *C.char) *C.char {
|
||||||
r.Error = err
|
r.Error = err
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
}
|
}
|
||||||
p, ok := i.(*plugin.RemoteConfig)
|
p, ok := i.(plugin.Config)
|
||||||
if !ok {
|
if !ok {
|
||||||
r.Error = errors.New("failed to load requested plugin")
|
r.Error = errors.New("failed to load requested plugin")
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
}
|
}
|
||||||
r.Result, r.Error = p.Config.ConfigAttributes()
|
r.Result, r.Error = p.ConfigAttributes()
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ func ConfigValidate(pluginName, pluginType, data, machData *C.char) *C.char {
|
||||||
r.Error = err
|
r.Error = err
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
}
|
}
|
||||||
p, ok := i.(*plugin.RemoteConfig)
|
p, ok := i.(plugin.Config)
|
||||||
if !ok {
|
if !ok {
|
||||||
r.Error = errors.New("failed to load requested plugin")
|
r.Error = errors.New("failed to load requested plugin")
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
|
@ -71,7 +71,7 @@ func ConfigValidate(pluginName, pluginType, data, machData *C.char) *C.char {
|
||||||
if r.Error != nil {
|
if r.Error != nil {
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
}
|
}
|
||||||
r.Result, r.Error = p.Config.ConfigValidate(cdata, m)
|
r.Result, r.Error = p.ConfigValidate(cdata, m)
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ func ConfigFinalize(pluginName, pluginType, data *C.char) *C.char {
|
||||||
r.Error = err
|
r.Error = err
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
}
|
}
|
||||||
p, ok := i.(*plugin.RemoteConfig)
|
p, ok := i.(plugin.Config)
|
||||||
if !ok {
|
if !ok {
|
||||||
r.Error = errors.New("failed to load requested plugin")
|
r.Error = errors.New("failed to load requested plugin")
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
|
@ -91,7 +91,7 @@ func ConfigFinalize(pluginName, pluginType, data *C.char) *C.char {
|
||||||
var cdata map[string]interface{}
|
var cdata map[string]interface{}
|
||||||
r.Error = json.Unmarshal([]byte(to_gs(data)), &cdata)
|
r.Error = json.Unmarshal([]byte(to_gs(data)), &cdata)
|
||||||
if r.Error == nil {
|
if r.Error == nil {
|
||||||
r.Result, r.Error = p.Config.ConfigFinalize(cdata)
|
r.Result, r.Error = p.ConfigFinalize(cdata)
|
||||||
}
|
}
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,11 +23,9 @@ func TestConfig_Load(t *testing.T) {
|
||||||
t.Fatalf("bad %#v", raw)
|
t.Fatalf("bad %#v", raw)
|
||||||
}
|
}
|
||||||
|
|
||||||
p := &vplugin.RemoteConfig{
|
|
||||||
Config: impl}
|
|
||||||
Plugins = vplugin.VagrantPluginInit()
|
Plugins = vplugin.VagrantPluginInit()
|
||||||
Plugins.PluginLookup = func(_, _ string) (r interface{}, err error) {
|
Plugins.PluginLookup = func(_, _ string) (r interface{}, err error) {
|
||||||
r = p
|
r = impl
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,11 +71,9 @@ func TestConfig_Attributes(t *testing.T) {
|
||||||
t.Fatalf("bad %#v", raw)
|
t.Fatalf("bad %#v", raw)
|
||||||
}
|
}
|
||||||
|
|
||||||
p := &vplugin.RemoteConfig{
|
|
||||||
Config: impl}
|
|
||||||
Plugins = vplugin.VagrantPluginInit()
|
Plugins = vplugin.VagrantPluginInit()
|
||||||
Plugins.PluginLookup = func(_, _ string) (r interface{}, err error) {
|
Plugins.PluginLookup = func(_, _ string) (r interface{}, err error) {
|
||||||
r = p
|
r = impl
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,11 +116,9 @@ func TestConfig_Validate(t *testing.T) {
|
||||||
t.Fatalf("bad %#v", raw)
|
t.Fatalf("bad %#v", raw)
|
||||||
}
|
}
|
||||||
|
|
||||||
p := &vplugin.RemoteConfig{
|
|
||||||
Config: impl}
|
|
||||||
Plugins = vplugin.VagrantPluginInit()
|
Plugins = vplugin.VagrantPluginInit()
|
||||||
Plugins.PluginLookup = func(_, _ string) (r interface{}, err error) {
|
Plugins.PluginLookup = func(_, _ string) (r interface{}, err error) {
|
||||||
r = p
|
r = impl
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,11 +164,9 @@ func TestConfig_Finalize(t *testing.T) {
|
||||||
t.Fatalf("bad %#v", raw)
|
t.Fatalf("bad %#v", raw)
|
||||||
}
|
}
|
||||||
|
|
||||||
p := &vplugin.RemoteConfig{
|
|
||||||
Config: impl}
|
|
||||||
Plugins = vplugin.VagrantPluginInit()
|
Plugins = vplugin.VagrantPluginInit()
|
||||||
Plugins.PluginLookup = func(_, _ string) (r interface{}, err error) {
|
Plugins.PluginLookup = func(_, _ string) (r interface{}, err error) {
|
||||||
r = p
|
r = impl
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ func ProviderAction(providerName *C.char, actionName *C.char, machData *C.char)
|
||||||
r.Error = err
|
r.Error = err
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
}
|
}
|
||||||
p, ok := i.(*plugin.RemoteProvider)
|
p, ok := i.(plugin.Provider)
|
||||||
if !ok {
|
if !ok {
|
||||||
r.Error = errors.New("failed to load requested plugin")
|
r.Error = errors.New("failed to load requested plugin")
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
|
@ -42,7 +42,7 @@ func ProviderAction(providerName *C.char, actionName *C.char, machData *C.char)
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
}
|
}
|
||||||
aName := to_gs(actionName)
|
aName := to_gs(actionName)
|
||||||
r.Result, r.Error = p.Provider.Action(aName, m)
|
r.Result, r.Error = p.Action(aName, m)
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ func ProviderIsInstalled(providerName *C.char, machData *C.char) *C.char {
|
||||||
r.Error = err
|
r.Error = err
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
}
|
}
|
||||||
p, ok := i.(*plugin.RemoteProvider)
|
p, ok := i.(plugin.Provider)
|
||||||
if !ok {
|
if !ok {
|
||||||
r.Error = errors.New("failed to load requested plugin")
|
r.Error = errors.New("failed to load requested plugin")
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
|
@ -64,7 +64,7 @@ func ProviderIsInstalled(providerName *C.char, machData *C.char) *C.char {
|
||||||
r.Error = err
|
r.Error = err
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
}
|
}
|
||||||
r.Result, r.Error = p.Provider.IsInstalled(m)
|
r.Result, r.Error = p.IsInstalled(m)
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ func ProviderIsUsable(providerName *C.char, machData *C.char) *C.char {
|
||||||
r.Error = err
|
r.Error = err
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
}
|
}
|
||||||
p, ok := i.(*plugin.RemoteProvider)
|
p, ok := i.(plugin.Provider)
|
||||||
if !ok {
|
if !ok {
|
||||||
r.Error = errors.New("failed to load requested plugin")
|
r.Error = errors.New("failed to load requested plugin")
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
|
@ -87,7 +87,7 @@ func ProviderIsUsable(providerName *C.char, machData *C.char) *C.char {
|
||||||
r.Error = err
|
r.Error = err
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
}
|
}
|
||||||
r.Result, r.Error = p.Provider.IsUsable(m)
|
r.Result, r.Error = p.IsUsable(m)
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ func ProviderMachineIdChanged(providerName *C.char, machData *C.char) *C.char {
|
||||||
r.Error = err
|
r.Error = err
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
}
|
}
|
||||||
p, ok := i.(*plugin.RemoteProvider)
|
p, ok := i.(plugin.Provider)
|
||||||
if !ok {
|
if !ok {
|
||||||
r.Error = errors.New("failed to load requested plugin")
|
r.Error = errors.New("failed to load requested plugin")
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
|
@ -109,7 +109,7 @@ func ProviderMachineIdChanged(providerName *C.char, machData *C.char) *C.char {
|
||||||
r.Error = err
|
r.Error = err
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
}
|
}
|
||||||
r.Error = p.Provider.MachineIdChanged(m)
|
r.Error = p.MachineIdChanged(m)
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ func ProviderRunAction(providerName *C.char, actName *C.char, runData *C.char, m
|
||||||
r.Error = err
|
r.Error = err
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
}
|
}
|
||||||
p, ok := i.(*plugin.RemoteProvider)
|
p, ok := i.(plugin.Provider)
|
||||||
if !ok {
|
if !ok {
|
||||||
r.Error = errors.New("failed to load requested plugin")
|
r.Error = errors.New("failed to load requested plugin")
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
|
@ -138,7 +138,7 @@ func ProviderRunAction(providerName *C.char, actName *C.char, runData *C.char, m
|
||||||
r.Error = err
|
r.Error = err
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
}
|
}
|
||||||
r.Result, r.Error = p.Provider.RunAction(aName, rData, m)
|
r.Result, r.Error = p.RunAction(aName, rData, m)
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ func ProviderSshInfo(providerName *C.char, machData *C.char) *C.char {
|
||||||
r.Error = err
|
r.Error = err
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
}
|
}
|
||||||
p, ok := i.(*plugin.RemoteProvider)
|
p, ok := i.(plugin.Provider)
|
||||||
if !ok {
|
if !ok {
|
||||||
r.Error = errors.New("failed to load requested plugin")
|
r.Error = errors.New("failed to load requested plugin")
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
|
@ -160,7 +160,7 @@ func ProviderSshInfo(providerName *C.char, machData *C.char) *C.char {
|
||||||
r.Error = err
|
r.Error = err
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
}
|
}
|
||||||
r.Result, r.Error = p.Provider.SshInfo(m)
|
r.Result, r.Error = p.SshInfo(m)
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,7 +172,7 @@ func ProviderState(providerName *C.char, machData *C.char) *C.char {
|
||||||
r.Error = err
|
r.Error = err
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
}
|
}
|
||||||
p, ok := i.(*plugin.RemoteProvider)
|
p, ok := i.(plugin.Provider)
|
||||||
if !ok {
|
if !ok {
|
||||||
r.Error = errors.New("failed to load requested plugin")
|
r.Error = errors.New("failed to load requested plugin")
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
|
@ -182,6 +182,6 @@ func ProviderState(providerName *C.char, machData *C.char) *C.char {
|
||||||
r.Error = err
|
r.Error = err
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
}
|
}
|
||||||
r.Result, r.Error = p.Provider.State(m)
|
r.Result, r.Error = p.State(m)
|
||||||
return r.Dump()
|
return r.Dump()
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,11 +74,9 @@ func TestProvider_ProviderAction(t *testing.T) {
|
||||||
t.Fatalf("bad %#v", raw)
|
t.Fatalf("bad %#v", raw)
|
||||||
}
|
}
|
||||||
|
|
||||||
p := &vplugin.RemoteProvider{
|
|
||||||
Provider: impl}
|
|
||||||
Plugins = vplugin.VagrantPluginInit()
|
Plugins = vplugin.VagrantPluginInit()
|
||||||
Plugins.PluginLookup = func(_, _ string) (r interface{}, err error) {
|
Plugins.PluginLookup = func(_, _ string) (r interface{}, err error) {
|
||||||
r = p
|
r = impl
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,11 +106,9 @@ func TestProvider_ProviderIsInstalled(t *testing.T) {
|
||||||
t.Fatalf("bad %#v", raw)
|
t.Fatalf("bad %#v", raw)
|
||||||
}
|
}
|
||||||
|
|
||||||
p := &vplugin.RemoteProvider{
|
|
||||||
Provider: impl}
|
|
||||||
Plugins = vplugin.VagrantPluginInit()
|
Plugins = vplugin.VagrantPluginInit()
|
||||||
Plugins.PluginLookup = func(_, _ string) (r interface{}, err error) {
|
Plugins.PluginLookup = func(_, _ string) (r interface{}, err error) {
|
||||||
r = p
|
r = impl
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,11 +138,9 @@ func TestProvider_ProviderIsUsable(t *testing.T) {
|
||||||
t.Fatalf("bad %#v", raw)
|
t.Fatalf("bad %#v", raw)
|
||||||
}
|
}
|
||||||
|
|
||||||
p := &vplugin.RemoteProvider{
|
|
||||||
Provider: impl}
|
|
||||||
Plugins = vplugin.VagrantPluginInit()
|
Plugins = vplugin.VagrantPluginInit()
|
||||||
Plugins.PluginLookup = func(_, _ string) (r interface{}, err error) {
|
Plugins.PluginLookup = func(_, _ string) (r interface{}, err error) {
|
||||||
r = p
|
r = impl
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,11 +170,9 @@ func TestProvider_ProviderMachineIdChanged(t *testing.T) {
|
||||||
t.Fatalf("bad %#v", raw)
|
t.Fatalf("bad %#v", raw)
|
||||||
}
|
}
|
||||||
|
|
||||||
p := &vplugin.RemoteProvider{
|
|
||||||
Provider: impl}
|
|
||||||
Plugins = vplugin.VagrantPluginInit()
|
Plugins = vplugin.VagrantPluginInit()
|
||||||
Plugins.PluginLookup = func(_, _ string) (r interface{}, err error) {
|
Plugins.PluginLookup = func(_, _ string) (r interface{}, err error) {
|
||||||
r = p
|
r = impl
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,11 +198,9 @@ func TestProvider_ProviderRunAction(t *testing.T) {
|
||||||
t.Fatalf("bad %#v", raw)
|
t.Fatalf("bad %#v", raw)
|
||||||
}
|
}
|
||||||
|
|
||||||
p := &vplugin.RemoteProvider{
|
|
||||||
Provider: impl}
|
|
||||||
Plugins = vplugin.VagrantPluginInit()
|
Plugins = vplugin.VagrantPluginInit()
|
||||||
Plugins.PluginLookup = func(_, _ string) (r interface{}, err error) {
|
Plugins.PluginLookup = func(_, _ string) (r interface{}, err error) {
|
||||||
r = p
|
r = impl
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,11 +240,9 @@ func TestProvider_ProviderSshInfo(t *testing.T) {
|
||||||
t.Fatalf("bad %#v", raw)
|
t.Fatalf("bad %#v", raw)
|
||||||
}
|
}
|
||||||
|
|
||||||
p := &vplugin.RemoteProvider{
|
|
||||||
Provider: impl}
|
|
||||||
Plugins = vplugin.VagrantPluginInit()
|
Plugins = vplugin.VagrantPluginInit()
|
||||||
Plugins.PluginLookup = func(_, _ string) (r interface{}, err error) {
|
Plugins.PluginLookup = func(_, _ string) (r interface{}, err error) {
|
||||||
r = p
|
r = impl
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,11 +280,9 @@ func TestProvider_ProviderState(t *testing.T) {
|
||||||
t.Fatalf("bad %#v", raw)
|
t.Fatalf("bad %#v", raw)
|
||||||
}
|
}
|
||||||
|
|
||||||
p := &vplugin.RemoteProvider{
|
|
||||||
Provider: impl}
|
|
||||||
Plugins = vplugin.VagrantPluginInit()
|
Plugins = vplugin.VagrantPluginInit()
|
||||||
Plugins.PluginLookup = func(_, _ string) (r interface{}, err error) {
|
Plugins.PluginLookup = func(_, _ string) (r interface{}, err error) {
|
||||||
r = p
|
r = impl
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,36 +19,64 @@ var (
|
||||||
ProtocolVersion: 1}
|
ProtocolVersion: 1}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type RemotePlugin interface {
|
||||||
|
Impl() interface{}
|
||||||
|
}
|
||||||
|
|
||||||
type RemoteConfig struct {
|
type RemoteConfig struct {
|
||||||
Client *go_plugin.Client
|
Client *go_plugin.Client
|
||||||
Config vagrant.Config
|
Config vagrant.Config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *RemoteConfig) Impl() interface{} {
|
||||||
|
return r.Config
|
||||||
|
}
|
||||||
|
|
||||||
type RemoteProvider struct {
|
type RemoteProvider struct {
|
||||||
Client *go_plugin.Client
|
Client *go_plugin.Client
|
||||||
Provider Provider
|
Provider Provider
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *RemoteProvider) Impl() interface{} {
|
||||||
|
return r.Provider
|
||||||
|
}
|
||||||
|
|
||||||
type RemoteGuestCapabilities struct {
|
type RemoteGuestCapabilities struct {
|
||||||
Client *go_plugin.Client
|
Client *go_plugin.Client
|
||||||
GuestCapabilities vagrant.GuestCapabilities
|
GuestCapabilities vagrant.GuestCapabilities
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *RemoteGuestCapabilities) Impl() interface{} {
|
||||||
|
return r.GuestCapabilities
|
||||||
|
}
|
||||||
|
|
||||||
type RemoteHostCapabilities struct {
|
type RemoteHostCapabilities struct {
|
||||||
Client *go_plugin.Client
|
Client *go_plugin.Client
|
||||||
HostCapabilities vagrant.HostCapabilities
|
HostCapabilities vagrant.HostCapabilities
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *RemoteHostCapabilities) Impl() interface{} {
|
||||||
|
return r.HostCapabilities
|
||||||
|
}
|
||||||
|
|
||||||
type RemoteProviderCapabilities struct {
|
type RemoteProviderCapabilities struct {
|
||||||
Client *go_plugin.Client
|
Client *go_plugin.Client
|
||||||
ProviderCapabilities vagrant.ProviderCapabilities
|
ProviderCapabilities vagrant.ProviderCapabilities
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *RemoteProviderCapabilities) Impl() interface{} {
|
||||||
|
return r.ProviderCapabilities
|
||||||
|
}
|
||||||
|
|
||||||
type RemoteSyncedFolder struct {
|
type RemoteSyncedFolder struct {
|
||||||
Client *go_plugin.Client
|
Client *go_plugin.Client
|
||||||
SyncedFolder vagrant.SyncedFolder
|
SyncedFolder vagrant.SyncedFolder
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *RemoteSyncedFolder) Impl() interface{} {
|
||||||
|
return r.SyncedFolder
|
||||||
|
}
|
||||||
|
|
||||||
type VagrantPlugin struct {
|
type VagrantPlugin struct {
|
||||||
Providers map[string]*RemoteProvider
|
Providers map[string]*RemoteProvider
|
||||||
SyncedFolders map[string]*RemoteSyncedFolder
|
SyncedFolders map[string]*RemoteSyncedFolder
|
||||||
|
@ -70,9 +98,9 @@ func VagrantPluginInit() *VagrantPlugin {
|
||||||
func (v *VagrantPlugin) DefaultPluginLookup(name, kind string) (p interface{}, err error) {
|
func (v *VagrantPlugin) DefaultPluginLookup(name, kind string) (p interface{}, err error) {
|
||||||
switch kind {
|
switch kind {
|
||||||
case "provider":
|
case "provider":
|
||||||
p = v.Providers[name]
|
p = v.Providers[name].Impl()
|
||||||
case "synced_folder":
|
case "synced_folder":
|
||||||
p = v.SyncedFolders[name]
|
p = v.SyncedFolders[name].Impl()
|
||||||
default:
|
default:
|
||||||
err = errors.New("invalid plugin type")
|
err = errors.New("invalid plugin type")
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue