Skip to content

Commit bd6949c

Browse files
committed
more wiring
1 parent 7ad4ae1 commit bd6949c

File tree

4 files changed

+40
-1
lines changed

4 files changed

+40
-1
lines changed

internal/proto6server/server_validatelistresourceconfig.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ import (
77
)
88

99
func (s *Server) ValidateListResourceConfig(ctx context.Context, request *tfprotov6.ValidateListResourceConfigRequest) (*tfprotov6.ValidateListResourceConfigResponse, error) {
10-
return nil, nil
10+
return &tfprotov6.ValidateListResourceConfigResponse{}, nil
1111
}

internal/toproto6/getmetadata.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ func GetMetadataResponse(ctx context.Context, fw *fwserver.GetMetadataResponse)
2121
DataSources: make([]tfprotov6.DataSourceMetadata, 0, len(fw.DataSources)),
2222
Diagnostics: Diagnostics(ctx, fw.Diagnostics),
2323
EphemeralResources: make([]tfprotov6.EphemeralResourceMetadata, 0, len(fw.EphemeralResources)),
24+
ListResources: make([]tfprotov6.ListResourceMetadata, 0, len(fw.ListResources)),
2425
Functions: make([]tfprotov6.FunctionMetadata, 0, len(fw.Functions)),
2526
Resources: make([]tfprotov6.ResourceMetadata, 0, len(fw.Resources)),
2627
ServerCapabilities: ServerCapabilities(ctx, fw.ServerCapabilities),
@@ -38,6 +39,10 @@ func GetMetadataResponse(ctx context.Context, fw *fwserver.GetMetadataResponse)
3839
protov6.Functions = append(protov6.Functions, FunctionMetadata(ctx, function))
3940
}
4041

42+
for _, listResource := range fw.ListResources {
43+
protov6.ListResources = append(protov6.ListResources, ListResourceMetadata(ctx, listResource))
44+
}
45+
4146
for _, resource := range fw.Resources {
4247
protov6.Resources = append(protov6.Resources, ResourceMetadata(ctx, resource))
4348
}

internal/toproto6/getproviderschema.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ func GetProviderSchemaResponse(ctx context.Context, fw *fwserver.GetProviderSche
2222
Diagnostics: Diagnostics(ctx, fw.Diagnostics),
2323
EphemeralResourceSchemas: make(map[string]*tfprotov6.Schema, len(fw.EphemeralResourceSchemas)),
2424
Functions: make(map[string]*tfprotov6.Function, len(fw.FunctionDefinitions)),
25+
ListResourceSchemas: make(map[string]*tfprotov6.Schema, len(fw.ListResourceSchemas)),
2526
ResourceSchemas: make(map[string]*tfprotov6.Schema, len(fw.ResourceSchemas)),
2627
ServerCapabilities: ServerCapabilities(ctx, fw.ServerCapabilities),
2728
}
@@ -70,6 +71,20 @@ func GetProviderSchemaResponse(ctx context.Context, fw *fwserver.GetProviderSche
7071
protov6.Functions[name] = Function(ctx, functionDefinition)
7172
}
7273

74+
for listResourceType, listResourceSchema := range fw.ListResourceSchemas {
75+
protov6.ListResourceSchemas[listResourceType], err = Schema(ctx, listResourceSchema)
76+
77+
if err != nil {
78+
protov6.Diagnostics = append(protov6.Diagnostics, &tfprotov6.Diagnostic{
79+
Severity: tfprotov6.DiagnosticSeverityError,
80+
Summary: "Error converting listResource schema",
81+
Detail: "The schema for the listResource \"" + listResourceType + "\" couldn't be converted into a usable type. This is always a problem with the provider. Please report the following to the provider developer:\n\n" + err.Error(),
82+
})
83+
84+
return protov6
85+
}
86+
}
87+
7388
for resourceType, resourceSchema := range fw.ResourceSchemas {
7489
protov6.ResourceSchemas[resourceType], err = Schema(ctx, resourceSchema)
7590

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright (c) HashiCorp, Inc.
2+
// SPDX-License-Identifier: MPL-2.0
3+
4+
package toproto6
5+
6+
import (
7+
"context"
8+
9+
"github.com/hashicorp/terraform-plugin-framework/internal/fwserver"
10+
"github.com/hashicorp/terraform-plugin-go/tfprotov6"
11+
)
12+
13+
// ListResourceMetadata returns the tfprotov6.ListResourceMetadata for a
14+
// fwserver.ListResourceMetadata.
15+
func ListResourceMetadata(ctx context.Context, fw fwserver.ListResourceMetadata) tfprotov6.ListResourceMetadata {
16+
return tfprotov6.ListResourceMetadata{
17+
TypeName: fw.TypeName,
18+
}
19+
}

0 commit comments

Comments
 (0)