Skip to content

Include list resource schemas in provider json schemas (TF-25497) #37163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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: 2 additions & 0 deletions internal/command/jsonprovider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type Provider struct {
ResourceSchemas map[string]*Schema `json:"resource_schemas,omitempty"`
DataSourceSchemas map[string]*Schema `json:"data_source_schemas,omitempty"`
EphemeralResourceSchemas map[string]*Schema `json:"ephemeral_resource_schemas,omitempty"`
ListResourceSchemas map[string]*Schema `json:"list_resource_schemas,omitempty"`
Functions map[string]*jsonfunction.FunctionSignature `json:"functions,omitempty"`
ResourceIdentitySchemas map[string]*IdentitySchema `json:"resource_identity_schemas,omitempty"`
}
Expand Down Expand Up @@ -64,6 +65,7 @@ func marshalProvider(tps providers.ProviderSchema) *Provider {
ResourceSchemas: marshalSchemas(tps.ResourceTypes),
DataSourceSchemas: marshalSchemas(tps.DataSources),
EphemeralResourceSchemas: marshalSchemas(tps.EphemeralResourceTypes),
ListResourceSchemas: marshalSchemas(tps.ListResourceTypes),
Functions: jsonfunction.MarshalProviderFunctions(tps.Functions),
ResourceIdentitySchemas: marshalIdentitySchemas(tps.ResourceTypes),
}
Expand Down
32 changes: 32 additions & 0 deletions internal/command/jsonprovider/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func TestMarshalProvider(t *testing.T) {
ResourceSchemas: map[string]*Schema{},
DataSourceSchemas: map[string]*Schema{},
EphemeralResourceSchemas: map[string]*Schema{},
ListResourceSchemas: map[string]*Schema{},
ResourceIdentitySchemas: map[string]*IdentitySchema{},
},
},
Expand Down Expand Up @@ -208,6 +209,26 @@ func TestMarshalProvider(t *testing.T) {
},
},
},
ListResourceSchemas: map[string]*Schema{
"test_list_resource": {
Version: 1,
Block: &Block{
Attributes: map[string]*Attribute{
"filter": {
AttributeType: json.RawMessage(`"string"`),
Optional: true,
DescriptionKind: "plain",
},
"items": {
AttributeType: json.RawMessage(`["list","string"]`),
Required: true,
DescriptionKind: "plain",
},
},
DescriptionKind: "plain",
},
},
},
ResourceIdentitySchemas: map[string]*IdentitySchema{},
},
},
Expand Down Expand Up @@ -317,5 +338,16 @@ func testProvider() providers.ProviderSchema {
},
},
},
ListResourceTypes: map[string]providers.Schema{
"test_list_resource": {
Version: 1,
Body: &configschema.Block{
Attributes: map[string]*configschema.Attribute{
"filter": {Type: cty.String, Optional: true},
"items": {Type: cty.List(cty.String), Required: true},
},
},
},
},
}
}
Loading