Skip to content

Commit 3856820

Browse files
committed
return ListResourceSchemas in GetProviderSchema response and add tests
1 parent 0d6b0ea commit 3856820

File tree

2 files changed

+435
-95
lines changed

2 files changed

+435
-95
lines changed

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
}
@@ -98,5 +99,19 @@ func GetProviderSchemaResponse(ctx context.Context, fw *fwserver.GetProviderSche
9899
}
99100
}
100101

102+
for listResourceType, listResourceSchema := range fw.ListResourceSchemas {
103+
protov6.ListResourceSchemas[listResourceType], err = Schema(ctx, listResourceSchema)
104+
105+
if err != nil {
106+
protov6.Diagnostics = append(protov6.Diagnostics, &tfprotov6.Diagnostic{
107+
Severity: tfprotov6.DiagnosticSeverityError,
108+
Summary: "Error converting list resource schema",
109+
Detail: "The schema for the list resource \"" + 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(),
110+
})
111+
112+
return protov6
113+
}
114+
}
115+
101116
return protov6
102117
}

0 commit comments

Comments
 (0)