plugin: implement new interface methods
This commit is contained in:
parent
d6c059c43e
commit
498e23162d
|
@ -176,6 +176,24 @@ func (p *ResourceProvider) Refresh(
|
||||||
return resp.State, err
|
return resp.State, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *ResourceProvider) ImportState(
|
||||||
|
info *terraform.InstanceInfo) ([]*terraform.InstanceState, error) {
|
||||||
|
var resp ResourceProviderImportStateResponse
|
||||||
|
args := &ResourceProviderImportStateArgs{
|
||||||
|
Info: info,
|
||||||
|
}
|
||||||
|
|
||||||
|
err := p.Client.Call("Plugin.ImportState", args, &resp)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if resp.Error != nil {
|
||||||
|
err = resp.Error
|
||||||
|
}
|
||||||
|
|
||||||
|
return resp.State, err
|
||||||
|
}
|
||||||
|
|
||||||
func (p *ResourceProvider) Resources() []terraform.ResourceType {
|
func (p *ResourceProvider) Resources() []terraform.ResourceType {
|
||||||
var result []terraform.ResourceType
|
var result []terraform.ResourceType
|
||||||
|
|
||||||
|
@ -245,6 +263,15 @@ type ResourceProviderRefreshResponse struct {
|
||||||
Error *plugin.BasicError
|
Error *plugin.BasicError
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ResourceProviderImportStateArgs struct {
|
||||||
|
Info *terraform.InstanceInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
type ResourceProviderImportStateResponse struct {
|
||||||
|
State []*terraform.InstanceState
|
||||||
|
Error *plugin.BasicError
|
||||||
|
}
|
||||||
|
|
||||||
type ResourceProviderValidateArgs struct {
|
type ResourceProviderValidateArgs struct {
|
||||||
Config *terraform.ResourceConfig
|
Config *terraform.ResourceConfig
|
||||||
}
|
}
|
||||||
|
@ -361,6 +388,17 @@ func (s *ResourceProviderServer) Refresh(
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *ResourceProviderServer) ImportState(
|
||||||
|
args *ResourceProviderImportStateArgs,
|
||||||
|
result *ResourceProviderImportStateResponse) error {
|
||||||
|
states, err := s.Provider.ImportState(args.Info)
|
||||||
|
*result = ResourceProviderImportStateResponse{
|
||||||
|
State: states,
|
||||||
|
Error: plugin.NewBasicError(err),
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (s *ResourceProviderServer) Resources(
|
func (s *ResourceProviderServer) Resources(
|
||||||
nothing interface{},
|
nothing interface{},
|
||||||
result *[]terraform.ResourceType) error {
|
result *[]terraform.ResourceType) error {
|
||||||
|
|
|
@ -334,8 +334,8 @@ func TestResourceProvider_resources(t *testing.T) {
|
||||||
provider := raw.(terraform.ResourceProvider)
|
provider := raw.(terraform.ResourceProvider)
|
||||||
|
|
||||||
expected := []terraform.ResourceType{
|
expected := []terraform.ResourceType{
|
||||||
{"foo"},
|
terraform.ResourceType{Name: "foo"},
|
||||||
{"bar"},
|
terraform.ResourceType{Name: "bar", Importable: true},
|
||||||
}
|
}
|
||||||
|
|
||||||
p.ResourcesReturn = expected
|
p.ResourcesReturn = expected
|
||||||
|
|
Loading…
Reference in New Issue