/
provider.go
53 lines (43 loc) · 1.58 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
package provider
import (
"context"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/provider"
"github.com/hashicorp/terraform-plugin-framework/resource"
)
// provider satisfies the tfsdk.Provider interface and usually is included
// with all Resource and DataSource implementations.
type utilsProvider struct {
// configured is set to true at the end of the Configure method.
// This can be used in Resource and DataSource implementations to verify
// that the provider was previously configured.
configured bool
// version is set to the provider version on release, "dev" when the
// provider is built and ran locally, and "test" when running acceptance
// testing.
version string
}
// Metadata returns the provider type name.
func (p *utilsProvider) Metadata(_ context.Context, _ provider.MetadataRequest, resp *provider.MetadataResponse) {
resp.TypeName = "utils"
}
func (p *utilsProvider) Schema(ctx context.Context, req provider.SchemaRequest, resp *provider.SchemaResponse) {
}
func (p *utilsProvider) Configure(ctx context.Context, req provider.ConfigureRequest, resp *provider.ConfigureResponse) {
p.configured = true
}
func (p *utilsProvider) Resources(ctx context.Context) []func() resource.Resource {
return nil
}
func (p *utilsProvider) DataSources(ctx context.Context) []func() datasource.DataSource {
return []func() datasource.DataSource{
NewYamlMergeDataSource,
}
}
func New(version string) func() provider.Provider {
return func() provider.Provider {
return &utilsProvider{
version: version,
}
}
}