Skip to content

Commit

Permalink
all: Remove type assertions for Ephemeral RPC implementations (#268)
Browse files Browse the repository at this point in the history
* all: Remove type assertions for Ephemeral RPC implementations

* update with released version
  • Loading branch information
austinvalle authored Jan 23, 2025
1 parent 788b7cd commit e62d24c
Show file tree
Hide file tree
Showing 22 changed files with 77 additions and 437 deletions.
14 changes: 7 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ toolchain go1.22.7

require (
github.com/google/go-cmp v0.6.0
github.com/hashicorp/terraform-plugin-go v0.25.0
github.com/hashicorp/terraform-plugin-go v0.26.0
github.com/hashicorp/terraform-plugin-log v0.9.0
google.golang.org/grpc v1.67.1
google.golang.org/grpc v1.69.4
)

require (
Expand All @@ -17,7 +17,7 @@ require (
github.com/hashicorp/go-hclog v1.5.0 // indirect
github.com/hashicorp/go-plugin v1.6.2 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/hashicorp/terraform-registry-address v0.2.3 // indirect
github.com/hashicorp/terraform-registry-address v0.2.4 // indirect
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
Expand All @@ -26,9 +26,9 @@ require (
github.com/oklog/run v1.0.0 // indirect
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
golang.org/x/net v0.33.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/net v0.34.0 // indirect
golang.org/x/sys v0.29.0 // indirect
golang.org/x/text v0.21.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect
google.golang.org/protobuf v1.35.1 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 // indirect
google.golang.org/protobuf v1.36.3 // indirect
)
44 changes: 30 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,28 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/hashicorp/go-hclog v1.5.0 h1:bI2ocEMgcVlz55Oj1xZNBsVi900c7II+fWDyV9o+13c=
github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M=
github.com/hashicorp/go-plugin v1.6.2 h1:zdGAEd0V1lCaU0u+MxWQhtSDQmahpkwOun8U8EiRVog=
github.com/hashicorp/go-plugin v1.6.2/go.mod h1:CkgLQ5CZqNmdL9U9JzM532t8ZiYQ35+pj3b1FD37R0Q=
github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8=
github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/terraform-plugin-go v0.25.0 h1:oi13cx7xXA6QciMcpcFi/rwA974rdTxjqEhXJjbAyks=
github.com/hashicorp/terraform-plugin-go v0.25.0/go.mod h1:+SYagMYadJP86Kvn+TGeV+ofr/R3g4/If0O5sO96MVw=
github.com/hashicorp/terraform-plugin-go v0.26.0 h1:cuIzCv4qwigug3OS7iKhpGAbZTiypAfFQmw8aE65O2M=
github.com/hashicorp/terraform-plugin-go v0.26.0/go.mod h1:+CXjuLDiFgqR+GcrM5a2E2Kal5t5q2jb0E3D57tTdNY=
github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0=
github.com/hashicorp/terraform-plugin-log v0.9.0/go.mod h1:rKL8egZQ/eXSyDqzLUuwUYLVdlYeamldAHSxjUFADow=
github.com/hashicorp/terraform-registry-address v0.2.3 h1:2TAiKJ1A3MAkZlH1YI/aTVcLZRu7JseiXNRHbOAyoTI=
github.com/hashicorp/terraform-registry-address v0.2.3/go.mod h1:lFHA76T8jfQteVfT7caREqguFrW3c4MFSPhZB7HHgUM=
github.com/hashicorp/terraform-registry-address v0.2.4 h1:JXu/zHB2Ymg/TGVCRu10XqNa4Sh2bWcqCNyKWjnCPJA=
github.com/hashicorp/terraform-registry-address v0.2.4/go.mod h1:tUNYTVyCtU4OIGXXMDp7WNcJ+0W1B4nmstVDgHMjfAU=
github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S52uzrw4x0jKQ=
github.com/hashicorp/terraform-svchost v0.1.1/go.mod h1:mNsjQfZyf/Jhz35v6/0LWcv26+X7JPS+buii2c9/ctc=
github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE=
Expand Down Expand Up @@ -48,24 +54,34 @@ github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IU
github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok=
github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g=
github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds=
golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I=
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
go.opentelemetry.io/otel v1.31.0 h1:NsJcKPIW0D0H3NgzPDHmo0WW6SptzPdqg/L1zsIm2hY=
go.opentelemetry.io/otel v1.31.0/go.mod h1:O0C14Yl9FgkjqcCZAsE053C13OaddMYr/hz6clDkEJE=
go.opentelemetry.io/otel/metric v1.31.0 h1:FSErL0ATQAmYHUIzSezZibnyVlft1ybhy4ozRPcF2fE=
go.opentelemetry.io/otel/metric v1.31.0/go.mod h1:C3dEloVbLuYoX41KpmAhOqNriGbA+qqH6PQ5E5mUfnY=
go.opentelemetry.io/otel/sdk v1.31.0 h1:xLY3abVHYZ5HSfOg3l2E5LUj2Cwva5Y7yGxnSW9H5Gk=
go.opentelemetry.io/otel/sdk v1.31.0/go.mod h1:TfRbMdhvxIIr/B2N2LQW2S5v9m3gOQ/08KsbbO5BPT0=
go.opentelemetry.io/otel/sdk/metric v1.31.0 h1:i9hxxLJF/9kkvfHppyLL55aW7iIJz4JjxTeYusH7zMc=
go.opentelemetry.io/otel/sdk/metric v1.31.0/go.mod h1:CRInTMVvNhUKgSAMbKyTMxqOBC0zgyxzW55lZzX43Y8=
go.opentelemetry.io/otel/trace v1.31.0 h1:ffjsj1aRouKewfr85U2aGagJ46+MvodynlQ1HYdmJys=
go.opentelemetry.io/otel/trace v1.31.0/go.mod h1:TXZkRk7SM2ZQLtR6eoAWQFIHPvzQ06FJAsO1tJg480A=
golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0=
golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 h1:e7S5W7MGGLaSu8j3YjdezkZ+m1/Nm0uRVRMEMGk26Xs=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU=
google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E=
google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA=
google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 h1:X58yt85/IXCx0Y3ZwN6sEIKZzQtDEYaBWrDvErdXrRE=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI=
google.golang.org/grpc v1.69.4 h1:MF5TftSMkd8GLw/m0KM6V8CMOCY6NZ1NQDPGFgbTt4A=
google.golang.org/grpc v1.69.4/go.mod h1:vyjdE6jLBI76dgpDojsFGNaHlxdjXN9ghpnd2o7JGZ4=
google.golang.org/protobuf v1.36.3 h1:82DV7MYdb8anAVi3qge1wSnMDrnKK7ebr+I0hHRN1BU=
google.golang.org/protobuf v1.36.3/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
19 changes: 1 addition & 18 deletions tf5muxserver/mux_server_CloseEphemeralResource.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,8 @@ func (s *muxServer) CloseEphemeralResource(ctx context.Context, req *tfprotov5.C
}, nil
}

// TODO: Remove and call server.CloseEphemeralResource below directly once interface becomes required.
ephemeralResourceServer, ok := server.(tfprotov5.EphemeralResourceServer)
if !ok {
resp := &tfprotov5.CloseEphemeralResourceResponse{
Diagnostics: []*tfprotov5.Diagnostic{
{
Severity: tfprotov5.DiagnosticSeverityError,
Summary: "CloseEphemeralResource Not Implemented",
Detail: "A CloseEphemeralResource call was received by the provider, however the provider does not implement CloseEphemeralResource. " +
"Either upgrade the provider to a version that implements CloseEphemeralResource or this is a bug in Terraform that should be reported to the Terraform maintainers.",
},
},
}

return resp, nil
}

ctx = logging.Tfprotov5ProviderServerContext(ctx, server)
logging.MuxTrace(ctx, "calling downstream server")

return ephemeralResourceServer.CloseEphemeralResource(ctx, req)
return server.CloseEphemeralResource(ctx, req)
}
10 changes: 2 additions & 8 deletions tf5muxserver/mux_server_CloseEphemeralResource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,7 @@ func TestMuxServerCloseEphemeralResource(t *testing.T) {
t.Fatalf("unexpected error setting up factory: %s", err)
}

//nolint:staticcheck // Intentionally verifying interface implementation
ephemeralResourceServer, ok := muxServer.ProviderServer().(tfprotov5.ProviderServerWithEphemeralResources)
if !ok {
t.Fatal("muxServer should implement tfprotov5.ProviderServerWithEphemeralResources")
}

_, err = ephemeralResourceServer.CloseEphemeralResource(ctx, &tfprotov5.CloseEphemeralResourceRequest{
_, err = muxServer.ProviderServer().CloseEphemeralResource(ctx, &tfprotov5.CloseEphemeralResourceRequest{
TypeName: "test_ephemeral_resource_server1",
})

Expand All @@ -60,7 +54,7 @@ func TestMuxServerCloseEphemeralResource(t *testing.T) {
t.Errorf("unexpected test_ephemeral_resource_server1 CloseEphemeralResource called on server2")
}

_, err = ephemeralResourceServer.CloseEphemeralResource(ctx, &tfprotov5.CloseEphemeralResourceRequest{
_, err = muxServer.ProviderServer().CloseEphemeralResource(ctx, &tfprotov5.CloseEphemeralResourceRequest{
TypeName: "test_ephemeral_resource_server2",
})

Expand Down
19 changes: 1 addition & 18 deletions tf5muxserver/mux_server_OpenEphemeralResource.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,8 @@ func (s *muxServer) OpenEphemeralResource(ctx context.Context, req *tfprotov5.Op
}, nil
}

// TODO: Remove and call server.OpenEphemeralResource below directly once interface becomes required.
ephemeralResourceServer, ok := server.(tfprotov5.EphemeralResourceServer)
if !ok {
resp := &tfprotov5.OpenEphemeralResourceResponse{
Diagnostics: []*tfprotov5.Diagnostic{
{
Severity: tfprotov5.DiagnosticSeverityError,
Summary: "OpenEphemeralResource Not Implemented",
Detail: "A OpenEphemeralResource call was received by the provider, however the provider does not implement OpenEphemeralResource. " +
"Either upgrade the provider to a version that implements OpenEphemeralResource or this is a bug in Terraform that should be reported to the Terraform maintainers.",
},
},
}

return resp, nil
}

ctx = logging.Tfprotov5ProviderServerContext(ctx, server)
logging.MuxTrace(ctx, "calling downstream server")

return ephemeralResourceServer.OpenEphemeralResource(ctx, req)
return server.OpenEphemeralResource(ctx, req)
}
10 changes: 2 additions & 8 deletions tf5muxserver/mux_server_OpenEphemeralResource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,7 @@ func TestMuxServerOpenEphemeralResource(t *testing.T) {
t.Fatalf("unexpected error setting up factory: %s", err)
}

//nolint:staticcheck // Intentionally verifying interface implementation
ephemeralResourceServer, ok := muxServer.ProviderServer().(tfprotov5.ProviderServerWithEphemeralResources)
if !ok {
t.Fatal("muxServer should implement tfprotov5.ProviderServerWithEphemeralResources")
}

_, err = ephemeralResourceServer.OpenEphemeralResource(ctx, &tfprotov5.OpenEphemeralResourceRequest{
_, err = muxServer.ProviderServer().OpenEphemeralResource(ctx, &tfprotov5.OpenEphemeralResourceRequest{
TypeName: "test_ephemeral_resource_server1",
})

Expand All @@ -60,7 +54,7 @@ func TestMuxServerOpenEphemeralResource(t *testing.T) {
t.Errorf("unexpected test_ephemeral_resource_server1 OpenEphemeralResource called on server2")
}

_, err = ephemeralResourceServer.OpenEphemeralResource(ctx, &tfprotov5.OpenEphemeralResourceRequest{
_, err = muxServer.ProviderServer().OpenEphemeralResource(ctx, &tfprotov5.OpenEphemeralResourceRequest{
TypeName: "test_ephemeral_resource_server2",
})

Expand Down
19 changes: 1 addition & 18 deletions tf5muxserver/mux_server_RenewEphemeralResource.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,8 @@ func (s *muxServer) RenewEphemeralResource(ctx context.Context, req *tfprotov5.R
}, nil
}

// TODO: Remove and call server.RenewEphemeralResource below directly once interface becomes required.
ephemeralResourceServer, ok := server.(tfprotov5.EphemeralResourceServer)
if !ok {
resp := &tfprotov5.RenewEphemeralResourceResponse{
Diagnostics: []*tfprotov5.Diagnostic{
{
Severity: tfprotov5.DiagnosticSeverityError,
Summary: "RenewEphemeralResource Not Implemented",
Detail: "A RenewEphemeralResource call was received by the provider, however the provider does not implement RenewEphemeralResource. " +
"Either upgrade the provider to a version that implements RenewEphemeralResource or this is a bug in Terraform that should be reported to the Terraform maintainers.",
},
},
}

return resp, nil
}

ctx = logging.Tfprotov5ProviderServerContext(ctx, server)
logging.MuxTrace(ctx, "calling downstream server")

return ephemeralResourceServer.RenewEphemeralResource(ctx, req)
return server.RenewEphemeralResource(ctx, req)
}
10 changes: 2 additions & 8 deletions tf5muxserver/mux_server_RenewEphemeralResource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,7 @@ func TestMuxServerRenewEphemeralResource(t *testing.T) {
t.Fatalf("unexpected error setting up factory: %s", err)
}

//nolint:staticcheck // Intentionally verifying interface implementation
ephemeralResourceServer, ok := muxServer.ProviderServer().(tfprotov5.ProviderServerWithEphemeralResources)
if !ok {
t.Fatal("muxServer should implement tfprotov5.ProviderServerWithEphemeralResources")
}

_, err = ephemeralResourceServer.RenewEphemeralResource(ctx, &tfprotov5.RenewEphemeralResourceRequest{
_, err = muxServer.ProviderServer().RenewEphemeralResource(ctx, &tfprotov5.RenewEphemeralResourceRequest{
TypeName: "test_ephemeral_resource_server1",
})

Expand All @@ -60,7 +54,7 @@ func TestMuxServerRenewEphemeralResource(t *testing.T) {
t.Errorf("unexpected test_ephemeral_resource_server1 RenewEphemeralResource called on server2")
}

_, err = ephemeralResourceServer.RenewEphemeralResource(ctx, &tfprotov5.RenewEphemeralResourceRequest{
_, err = muxServer.ProviderServer().RenewEphemeralResource(ctx, &tfprotov5.RenewEphemeralResourceRequest{
TypeName: "test_ephemeral_resource_server2",
})

Expand Down
19 changes: 1 addition & 18 deletions tf5muxserver/mux_server_ValidateEphemeralResourceConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,8 @@ func (s *muxServer) ValidateEphemeralResourceConfig(ctx context.Context, req *tf
}, nil
}

// TODO: Remove and call server.ValidateEphemeralResourceConfig below directly once interface becomes required.
ephemeralResourceServer, ok := server.(tfprotov5.EphemeralResourceServer)
if !ok {
resp := &tfprotov5.ValidateEphemeralResourceConfigResponse{
Diagnostics: []*tfprotov5.Diagnostic{
{
Severity: tfprotov5.DiagnosticSeverityError,
Summary: "ValidateEphemeralResourceConfig Not Implemented",
Detail: "A ValidateEphemeralResourceConfig call was received by the provider, however the provider does not implement ValidateEphemeralResourceConfig. " +
"Either upgrade the provider to a version that implements ValidateEphemeralResourceConfig or this is a bug in Terraform that should be reported to the Terraform maintainers.",
},
},
}

return resp, nil
}

ctx = logging.Tfprotov5ProviderServerContext(ctx, server)
logging.MuxTrace(ctx, "calling downstream server")

return ephemeralResourceServer.ValidateEphemeralResourceConfig(ctx, req)
return server.ValidateEphemeralResourceConfig(ctx, req)
}
10 changes: 2 additions & 8 deletions tf5muxserver/mux_server_ValidateEphemeralResourceConfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,7 @@ func TestMuxServerValidateEphemeralResourceConfig(t *testing.T) {
t.Fatalf("unexpected error setting up factory: %s", err)
}

//nolint:staticcheck // Intentionally verifying interface implementation
ephemeralResourceServer, ok := muxServer.ProviderServer().(tfprotov5.ProviderServerWithEphemeralResources)
if !ok {
t.Fatal("muxServer should implement tfprotov5.ProviderServerWithEphemeralResources")
}

_, err = ephemeralResourceServer.ValidateEphemeralResourceConfig(ctx, &tfprotov5.ValidateEphemeralResourceConfigRequest{
_, err = muxServer.ProviderServer().ValidateEphemeralResourceConfig(ctx, &tfprotov5.ValidateEphemeralResourceConfigRequest{
TypeName: "test_ephemeral_resource_server1",
})

Expand All @@ -60,7 +54,7 @@ func TestMuxServerValidateEphemeralResourceConfig(t *testing.T) {
t.Errorf("unexpected test_ephemeral_resource_server1 ValidateEphemeralResourceConfig called on server2")
}

_, err = ephemeralResourceServer.ValidateEphemeralResourceConfig(ctx, &tfprotov5.ValidateEphemeralResourceConfigRequest{
_, err = muxServer.ProviderServer().ValidateEphemeralResourceConfig(ctx, &tfprotov5.ValidateEphemeralResourceConfigRequest{
TypeName: "test_ephemeral_resource_server2",
})

Expand Down
Loading

0 comments on commit e62d24c

Please sign in to comment.