Skip to content

Commit 9b5e176

Browse files
committed
tidy
1 parent 8d92c15 commit 9b5e176

File tree

5 files changed

+61
-9
lines changed

5 files changed

+61
-9
lines changed

hats.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Copyright (c) HashiCorp, Inc.
2+
// SPDX-License-Identifier: MPL-2.0
3+
4+
package
5+
type ResourceWithList interface {
6+
Resource
7+
8+
ListSchema(context.Context, SchemaRequest, SchemaResponse)
9+
List(context.Context, ListRequest, ListResponse)
10+
}
11+
12+
type ResourceWithValidateListConfig interface {
13+
ResourceWithList
14+
15+
ValidateListConfig(
16+
context.Context,
17+
ValidateListConfigRequest,
18+
ValidateListConfigResponse)
19+
}
20+
21+
type ListRequest struct {
22+
Config tfsdk.Config
23+
IncludeResourceObject bool
24+
}
25+
26+
type ListResponse struct {
27+
Results []ListResult
28+
}
29+
30+
type ListResult struct {
31+
Identity tfsdk.ResourceIdentity
32+
Resource tfsdk.State
33+
DisplayName string
34+
Diagnostics diag.Diagnostics
35+
}
36+
37+
type ValidateListConfigRequest struct {
38+
Config tfsdk.Config
39+
}
40+
41+
type ValidateListConfigResponse struct {
42+
Diagnostics diag.Diagnostics
43+
}

internal/fwserver/server_getproviderschema.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ type GetProviderSchemaResponse struct {
2424
ResourceSchemas map[string]fwschema.Schema
2525
DataSourceSchemas map[string]fwschema.Schema
2626
EphemeralResourceSchemas map[string]fwschema.Schema
27+
ListSchemas map[string]fwschema.Schema
2728
FunctionDefinitions map[string]function.Definition
2829
Diagnostics diag.Diagnostics
2930
}

resource/list.go

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ type List interface {
2424
// such as examplecloud_thing..
2525
Metadata(context.Context, MetadataRequest, *MetadataResponse)
2626

27-
// Schema should return the schema for list blocks.
28-
ListSchema(context.Context, SchemaRequest, SchemaResponse)
27+
// ListConfigSchema should return the schema for list blocks.
28+
ListConfigSchema(context.Context, SchemaRequest, SchemaResponse)
2929

3030
// ListResources is called when the provider must list instances of a
3131
// managed resource type that satisfy a user-provided request.
@@ -38,9 +38,7 @@ type List interface {
3838
type ListWithConfigure interface {
3939
List
4040

41-
// Configure enables provider-level data or clients to be set in the
42-
// provider-defined Resource type. It is separately executed for each
43-
// ReadResource RPC.
41+
// Configure enables provider-level data or clients to be set.
4442
Configure(context.Context, ConfigureRequest, *ConfigureResponse)
4543
}
4644

@@ -110,8 +108,18 @@ type ListResponse struct {
110108
// function implementation will emit zero or more results for a user-provided
111109
// request.
112110
type ListResult struct {
113-
Identity tfsdk.ResourceIdentity
114-
Resource tfsdk.ResourceObject
111+
// Identity is the identity of the managed resource instance.
112+
//
113+
// A nil value will raise will raise a diagnostic.
114+
Identity *tfsdk.ResourceIdentity
115+
116+
// ResourceObject is the provider's representation of all attributes of the
117+
// managed resource instance.
118+
//
119+
// If ListRequest.IncludeResourceObject is true, a nil value will raise
120+
// a warning diagnostic.
121+
Resource *tfsdk.ResourceObject
122+
115123
DisplayName string
116124
Diagnostics diag.Diagnostics
117125
}

resource/list_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func (c *ComputeInstance) Configure(_ context.Context, _ resource.ConfigureReque
2424
panic("not implemented")
2525
}
2626

27-
func (c *ComputeInstance) ListSchema(_ context.Context, _ resource.SchemaRequest, _ resource.SchemaResponse) {
27+
func (c *ComputeInstance) ListConfigSchema(_ context.Context, _ resource.SchemaRequest, _ resource.SchemaResponse) {
2828
panic("not implemented")
2929
}
3030

resource/resource.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ type ResourceWithConfigure interface {
7575

7676
// ResourceWithConfigValidators is an interface type that extends Resource to include declarative validations.
7777
//
78-
// Declaring validation using this methodology simplifies implmentation of
78+
// Declaring validation using this methodology simplifies implementation of
7979
// reusable functionality. These also include descriptions, which can be used
8080
// for automating documentation.
8181
//

0 commit comments

Comments
 (0)