/
provider.go
81 lines (68 loc) · 2.07 KB
/
provider.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package framework
import (
"context"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/function"
"github.com/hashicorp/terraform-plugin-framework/provider"
"github.com/hashicorp/terraform-plugin-framework/provider/schema"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-provider-corner/internal/backend"
)
var (
_ provider.ProviderWithFunctions = (*testProvider)(nil)
)
func New() provider.Provider {
return &testProvider{}
}
type testProvider struct{}
func (p *testProvider) Metadata(_ context.Context, _ provider.MetadataRequest, resp *provider.MetadataResponse) {
resp.TypeName = "framework"
}
func (p *testProvider) Schema(_ context.Context, _ provider.SchemaRequest, resp *provider.SchemaResponse) {
resp.Schema = schema.Schema{
Attributes: map[string]schema.Attribute{
"dummy": schema.StringAttribute{
Optional: true,
},
},
}
}
func (p *testProvider) Configure(ctx context.Context, req provider.ConfigureRequest, resp *provider.ConfigureResponse) {
client, err := backend.NewClient()
if err != nil {
resp.Diagnostics.AddError("Error initialising client", err.Error())
}
resp.ResourceData = client
}
func (p *testProvider) Resources(_ context.Context) []func() resource.Resource {
return []func() resource.Resource{
NewSchemaResource,
NewDynamicSchemaResource,
NewDynamicComputedTypeChangeResource,
NewTimeoutsResource,
NewUserResource,
NewFloat64PrecisionResource,
}
}
func (p *testProvider) DataSources(_ context.Context) []func() datasource.DataSource {
return nil
}
func (p *testProvider) Functions(ctx context.Context) []func() function.Function {
return []func() function.Function{
NewBoolFunction,
NewDynamicFunction,
NewFloat64Function,
NewInt64Function,
NewListFunction,
NewMapFunction,
NewNumberFunction,
NewObjectFunction,
NewObjectWithDynamicFunction,
NewSetFunction,
NewStringFunction,
NewVariadicFunction,
NewDynamicVariadicFunction,
}
}