Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/tfprotov5tov6/tfprotov5tov6.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ func GetMetadataResponse(in *tfprotov5.GetMetadataResponse) *tfprotov6.GetMetada
DataSources: make([]tfprotov6.DataSourceMetadata, 0, len(in.DataSources)),
Diagnostics: Diagnostics(in.Diagnostics),
EphemeralResources: make([]tfprotov6.EphemeralResourceMetadata, 0, len(in.Resources)),
ListResources: make([]tfprotov6.ListResourceMetadata, 0, len(in.Resources)),
ListResources: make([]tfprotov6.ListResourceMetadata, 0, len(in.ListResources)),
Functions: make([]tfprotov6.FunctionMetadata, 0, len(in.Functions)),
Resources: make([]tfprotov6.ResourceMetadata, 0, len(in.Resources)),
ServerCapabilities: ServerCapabilities(in.ServerCapabilities),
Expand Down
2 changes: 1 addition & 1 deletion internal/tfprotov6tov5/tfprotov6tov5.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ func GetMetadataResponse(in *tfprotov6.GetMetadataResponse) *tfprotov5.GetMetada
DataSources: make([]tfprotov5.DataSourceMetadata, 0, len(in.DataSources)),
Diagnostics: Diagnostics(in.Diagnostics),
EphemeralResources: make([]tfprotov5.EphemeralResourceMetadata, 0, len(in.Resources)),
ListResources: make([]tfprotov5.ListResourceMetadata, 0, len(in.Resources)),
ListResources: make([]tfprotov5.ListResourceMetadata, 0, len(in.ListResources)),
Functions: make([]tfprotov5.FunctionMetadata, 0, len(in.Functions)),
Resources: make([]tfprotov5.ResourceMetadata, 0, len(in.Resources)),
ServerCapabilities: ServerCapabilities(in.ServerCapabilities),
Expand Down
85 changes: 85 additions & 0 deletions tf5muxserver/mux_server_GetMetadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func TestMuxServerGetMetadata(t *testing.T) {
expectedDataSources []tfprotov5.DataSourceMetadata
expectedDiagnostics []*tfprotov5.Diagnostic
expectedEphemeralResources []tfprotov5.EphemeralResourceMetadata
expectedListResources []tfprotov5.ListResourceMetadata
expectedFunctions []tfprotov5.FunctionMetadata
expectedResources []tfprotov5.ResourceMetadata
expectedServerCapabilities *tfprotov5.ServerCapabilities
Expand Down Expand Up @@ -56,6 +57,14 @@ func TestMuxServerGetMetadata(t *testing.T) {
TypeName: "test_bar",
},
},
ListResources: []tfprotov5.ListResourceMetadata{
{
TypeName: "test_foo",
},
{
TypeName: "test_bar",
},
},
},
}).ProviderServer,
(&tf5testserver.TestServer{
Expand Down Expand Up @@ -86,6 +95,11 @@ func TestMuxServerGetMetadata(t *testing.T) {
TypeName: "test_quux",
},
},
ListResources: []tfprotov5.ListResourceMetadata{
{
TypeName: "test_quux",
},
},
},
}).ProviderServer,
},
Expand Down Expand Up @@ -133,6 +147,17 @@ func TestMuxServerGetMetadata(t *testing.T) {
TypeName: "test_quux",
},
},
expectedListResources: []tfprotov5.ListResourceMetadata{
{
TypeName: "test_foo",
},
{
TypeName: "test_bar",
},
{
TypeName: "test_quux",
},
},
expectedServerCapabilities: &tfprotov5.ServerCapabilities{
GetProviderSchemaOptional: true,
MoveResourceState: true,
Expand Down Expand Up @@ -176,6 +201,7 @@ func TestMuxServerGetMetadata(t *testing.T) {
},
},
expectedEphemeralResources: []tfprotov5.EphemeralResourceMetadata{},
expectedListResources: []tfprotov5.ListResourceMetadata{},
expectedFunctions: []tfprotov5.FunctionMetadata{},
expectedResources: []tfprotov5.ResourceMetadata{},
expectedServerCapabilities: &tfprotov5.ServerCapabilities{
Expand Down Expand Up @@ -221,6 +247,53 @@ func TestMuxServerGetMetadata(t *testing.T) {
TypeName: "test_foo",
},
},
expectedListResources: []tfprotov5.ListResourceMetadata{},
expectedFunctions: []tfprotov5.FunctionMetadata{},
expectedResources: []tfprotov5.ResourceMetadata{},
expectedServerCapabilities: &tfprotov5.ServerCapabilities{
GetProviderSchemaOptional: true,
MoveResourceState: true,
PlanDestroy: true,
},
},
"duplicate-list-resource-type": {
servers: []func() tfprotov5.ProviderServer{
(&tf5testserver.TestServer{
GetMetadataResponse: &tfprotov5.GetMetadataResponse{
ListResources: []tfprotov5.ListResourceMetadata{
{
TypeName: "test_foo",
},
},
},
}).ProviderServer,
(&tf5testserver.TestServer{
GetMetadataResponse: &tfprotov5.GetMetadataResponse{
ListResources: []tfprotov5.ListResourceMetadata{
{
TypeName: "test_foo",
},
},
},
}).ProviderServer,
},
expectedDataSources: []tfprotov5.DataSourceMetadata{},
expectedDiagnostics: []*tfprotov5.Diagnostic{
{
Severity: tfprotov5.DiagnosticSeverityError,
Summary: "Invalid Provider Server Combination",
Detail: "The combined provider has multiple implementations of the same list resource type across underlying providers. " +
"List resource types must be implemented by only one underlying provider. " +
"This is always an issue in the provider implementation and should be reported to the provider developers.\n\n" +
"Duplicate list resource type: test_foo",
},
},
expectedEphemeralResources: []tfprotov5.EphemeralResourceMetadata{},
expectedListResources: []tfprotov5.ListResourceMetadata{
{
TypeName: "test_foo",
},
},
expectedFunctions: []tfprotov5.FunctionMetadata{},
expectedResources: []tfprotov5.ResourceMetadata{},
expectedServerCapabilities: &tfprotov5.ServerCapabilities{
Expand Down Expand Up @@ -262,6 +335,7 @@ func TestMuxServerGetMetadata(t *testing.T) {
},
},
expectedEphemeralResources: []tfprotov5.EphemeralResourceMetadata{},
expectedListResources: []tfprotov5.ListResourceMetadata{},
expectedFunctions: []tfprotov5.FunctionMetadata{
{
Name: "test_function",
Expand Down Expand Up @@ -307,6 +381,7 @@ func TestMuxServerGetMetadata(t *testing.T) {
},
},
expectedEphemeralResources: []tfprotov5.EphemeralResourceMetadata{},
expectedListResources: []tfprotov5.ListResourceMetadata{},
expectedFunctions: []tfprotov5.FunctionMetadata{},
expectedResources: []tfprotov5.ResourceMetadata{
{
Expand Down Expand Up @@ -347,6 +422,7 @@ func TestMuxServerGetMetadata(t *testing.T) {
},
expectedDataSources: []tfprotov5.DataSourceMetadata{},
expectedEphemeralResources: []tfprotov5.EphemeralResourceMetadata{},
expectedListResources: []tfprotov5.ListResourceMetadata{},
expectedFunctions: []tfprotov5.FunctionMetadata{},
expectedResources: []tfprotov5.ResourceMetadata{
{
Expand Down Expand Up @@ -387,6 +463,7 @@ func TestMuxServerGetMetadata(t *testing.T) {
},
},
expectedEphemeralResources: []tfprotov5.EphemeralResourceMetadata{},
expectedListResources: []tfprotov5.ListResourceMetadata{},
expectedFunctions: []tfprotov5.FunctionMetadata{},
expectedResources: []tfprotov5.ResourceMetadata{},
expectedServerCapabilities: &tfprotov5.ServerCapabilities{
Expand Down Expand Up @@ -435,6 +512,7 @@ func TestMuxServerGetMetadata(t *testing.T) {
},
},
expectedEphemeralResources: []tfprotov5.EphemeralResourceMetadata{},
expectedListResources: []tfprotov5.ListResourceMetadata{},
expectedFunctions: []tfprotov5.FunctionMetadata{},
expectedResources: []tfprotov5.ResourceMetadata{},
expectedServerCapabilities: &tfprotov5.ServerCapabilities{
Expand Down Expand Up @@ -468,6 +546,7 @@ func TestMuxServerGetMetadata(t *testing.T) {
},
},
expectedEphemeralResources: []tfprotov5.EphemeralResourceMetadata{},
expectedListResources: []tfprotov5.ListResourceMetadata{},
expectedFunctions: []tfprotov5.FunctionMetadata{},
expectedResources: []tfprotov5.ResourceMetadata{},
expectedServerCapabilities: &tfprotov5.ServerCapabilities{
Expand Down Expand Up @@ -516,6 +595,7 @@ func TestMuxServerGetMetadata(t *testing.T) {
},
},
expectedEphemeralResources: []tfprotov5.EphemeralResourceMetadata{},
expectedListResources: []tfprotov5.ListResourceMetadata{},
expectedFunctions: []tfprotov5.FunctionMetadata{},
expectedResources: []tfprotov5.ResourceMetadata{},
expectedServerCapabilities: &tfprotov5.ServerCapabilities{
Expand Down Expand Up @@ -564,6 +644,7 @@ func TestMuxServerGetMetadata(t *testing.T) {
},
},
expectedEphemeralResources: []tfprotov5.EphemeralResourceMetadata{},
expectedListResources: []tfprotov5.ListResourceMetadata{},
expectedFunctions: []tfprotov5.FunctionMetadata{},
expectedResources: []tfprotov5.ResourceMetadata{},
expectedServerCapabilities: &tfprotov5.ServerCapabilities{
Expand Down Expand Up @@ -603,6 +684,10 @@ func TestMuxServerGetMetadata(t *testing.T) {
t.Errorf("ephemeral resources didn't match expectations: %s", diff)
}

if diff := cmp.Diff(resp.ListResources, testCase.expectedListResources); diff != "" {
t.Errorf("list resources didn't match expectations: %s", diff)
}

if diff := cmp.Diff(resp.Functions, testCase.expectedFunctions); diff != "" {
t.Errorf("functions didn't match expectations: %s", diff)
}
Expand Down
Loading
Loading