|
|
|
|
@ -12,8 +12,8 @@ import (
|
|
|
|
|
"github.com/hashicorp/go-hclog"
|
|
|
|
|
"github.com/hashicorp/go-plugin"
|
|
|
|
|
"github.com/hashicorp/terraform/e2e"
|
|
|
|
|
"github.com/hashicorp/terraform/internal/legacy/builtin/providers/test"
|
|
|
|
|
grpcplugin "github.com/hashicorp/terraform/internal/legacy/helper/plugin"
|
|
|
|
|
"github.com/hashicorp/terraform/internal/grpcwrap"
|
|
|
|
|
simple "github.com/hashicorp/terraform/internal/provider-simple"
|
|
|
|
|
proto "github.com/hashicorp/terraform/internal/tfplugin5"
|
|
|
|
|
tfplugin "github.com/hashicorp/terraform/plugin"
|
|
|
|
|
)
|
|
|
|
|
@ -42,7 +42,7 @@ type reattachConfigAddr struct {
|
|
|
|
|
|
|
|
|
|
type providerServer struct {
|
|
|
|
|
sync.Mutex
|
|
|
|
|
*grpcplugin.GRPCProviderServer
|
|
|
|
|
proto.ProviderServer
|
|
|
|
|
planResourceChangeCalled bool
|
|
|
|
|
applyResourceChangeCalled bool
|
|
|
|
|
}
|
|
|
|
|
@ -52,7 +52,7 @@ func (p *providerServer) PlanResourceChange(ctx context.Context, req *proto.Plan
|
|
|
|
|
defer p.Unlock()
|
|
|
|
|
|
|
|
|
|
p.planResourceChangeCalled = true
|
|
|
|
|
return p.GRPCProviderServer.PlanResourceChange(ctx, req)
|
|
|
|
|
return p.ProviderServer.PlanResourceChange(ctx, req)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p *providerServer) ApplyResourceChange(ctx context.Context, req *proto.ApplyResourceChange_Request) (*proto.ApplyResourceChange_Response, error) {
|
|
|
|
|
@ -60,7 +60,7 @@ func (p *providerServer) ApplyResourceChange(ctx context.Context, req *proto.App
|
|
|
|
|
defer p.Unlock()
|
|
|
|
|
|
|
|
|
|
p.applyResourceChangeCalled = true
|
|
|
|
|
return p.GRPCProviderServer.ApplyResourceChange(ctx, req)
|
|
|
|
|
return p.ProviderServer.ApplyResourceChange(ctx, req)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p *providerServer) PlanResourceChangeCalled() bool {
|
|
|
|
|
@ -99,7 +99,7 @@ func TestUnmanagedSeparatePlan(t *testing.T) {
|
|
|
|
|
reattachCh := make(chan *plugin.ReattachConfig)
|
|
|
|
|
closeCh := make(chan struct{})
|
|
|
|
|
provider := &providerServer{
|
|
|
|
|
GRPCProviderServer: grpcplugin.NewGRPCProviderServerShim(test.Provider()),
|
|
|
|
|
ProviderServer: grpcwrap.New(simple.Provider()),
|
|
|
|
|
}
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
defer cancel()
|
|
|
|
|
@ -140,6 +140,7 @@ func TestUnmanagedSeparatePlan(t *testing.T) {
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
tf.AddEnv("TF_REATTACH_PROVIDERS=" + string(reattachStr))
|
|
|
|
|
tf.AddEnv("PLUGIN_PROTOCOL_VERSION=5")
|
|
|
|
|
|
|
|
|
|
@ -164,7 +165,7 @@ func TestUnmanagedSeparatePlan(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !provider.PlanResourceChangeCalled() {
|
|
|
|
|
t.Error("PlanResourceChange not called on in-process provider")
|
|
|
|
|
t.Error("PlanResourceChange not called on un-managed provider")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//// APPLY
|
|
|
|
|
@ -174,7 +175,7 @@ func TestUnmanagedSeparatePlan(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !provider.ApplyResourceChangeCalled() {
|
|
|
|
|
t.Error("ApplyResourceChange not called on in-process provider")
|
|
|
|
|
t.Error("ApplyResourceChange not called on un-managed provider")
|
|
|
|
|
}
|
|
|
|
|
provider.ResetApplyResourceChangeCalled()
|
|
|
|
|
|
|
|
|
|
|