forked from alchemy-fr/terraform-provider-sodium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprovider.go
55 lines (42 loc) · 1.52 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
package provider
import (
"context"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"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-plugin-log/tflog"
)
type sodiumProvider struct {
}
// Enforce interfaces we want provider to implement.
var _ provider.Provider = (*sodiumProvider)(nil)
func New() provider.Provider {
return &sodiumProvider{}
}
func (p *sodiumProvider) resetConfig() {
}
func (p *sodiumProvider) Metadata(_ context.Context, req provider.MetadataRequest, resp *provider.MetadataResponse) {
resp.TypeName = "sodium"
}
func (p *sodiumProvider) Schema(_ context.Context, req provider.SchemaRequest, resp *provider.SchemaResponse) {
resp.Schema = schema.Schema{
MarkdownDescription: "Provider configuration",
}
}
func (p *sodiumProvider) Configure(ctx context.Context, req provider.ConfigureRequest, res *provider.ConfigureResponse) {
tflog.Debug(ctx, "Configuring provider")
p.resetConfig()
// Since the provider instance is being passed, ensure these response
// values are always set before early returns, etc.
res.DataSourceData = p
res.ResourceData = p
}
func (p *sodiumProvider) Resources(_ context.Context) []func() resource.Resource {
return []func() resource.Resource{
NewKeyPairResource,
}
}
func (p *sodiumProvider) DataSources(_ context.Context) []func() datasource.DataSource {
return []func() datasource.DataSource{}
}