@@ -12,16 +12,27 @@ import (
12
12
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
13
13
"github.com/hashicorp/terraform-plugin-framework/datasource"
14
14
"github.com/hashicorp/terraform-plugin-framework/diag"
15
- "github.com/hashicorp/terraform-plugin-framework/provider"
16
15
"github.com/hashicorp/terraform-plugin-framework/tfsdk"
17
16
"github.com/hashicorp/terraform-plugin-framework/types"
18
17
)
19
18
20
- var _ provider.DataSourceType = (* httpDataSourceType )(nil )
19
+ var _ datasource.DataSource = (* httpDataSource )(nil )
20
+
21
+ func NewHttpDataSource () datasource.DataSource {
22
+ return & httpDataSource {}
23
+ }
21
24
22
- type httpDataSourceType struct {}
25
+ type httpDataSource struct {}
26
+
27
+ func (d * httpDataSource ) Metadata (_ context.Context , _ datasource.MetadataRequest , resp * datasource.MetadataResponse ) {
28
+ // This data source name unconventionally is equal to the provider name,
29
+ // but it has been named this since its inception. Changing this widely
30
+ // adopted data source name should only be done with strong consideration
31
+ // to the practitioner burden of updating it everywhere.
32
+ resp .TypeName = "http"
33
+ }
23
34
24
- func (d * httpDataSourceType ) GetSchema (context.Context ) (tfsdk.Schema , diag.Diagnostics ) {
35
+ func (d * httpDataSource ) GetSchema (context.Context ) (tfsdk.Schema , diag.Diagnostics ) {
25
36
return tfsdk.Schema {
26
37
Description : `
27
38
The ` + "`http`" + ` data source makes an HTTP GET request to the given URL and exports
@@ -111,14 +122,6 @@ your control should be treated as untrustworthy.`,
111
122
}, nil
112
123
}
113
124
114
- func (d * httpDataSourceType ) NewDataSource (context.Context , provider.Provider ) (datasource.DataSource , diag.Diagnostics ) {
115
- return & httpDataSource {}, nil
116
- }
117
-
118
- var _ datasource.DataSource = (* httpDataSource )(nil )
119
-
120
- type httpDataSource struct {}
121
-
122
125
func (d * httpDataSource ) Read (ctx context.Context , req datasource.ReadRequest , resp * datasource.ReadResponse ) {
123
126
var model modelV0
124
127
diags := req .Config .Get (ctx , & model )
0 commit comments