/
provider.go
51 lines (44 loc) · 2.16 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
package tfsdk
import (
"context"
"github.com/hashicorp/terraform-plugin-framework/diag"
)
// Provider is the core interface that all Terraform providers must implement.
type Provider interface {
// GetSchema returns the schema for this provider's configuration. If
// this provider has no configuration, return an empty schema.Schema.
GetSchema(context.Context) (Schema, diag.Diagnostics)
// Configure is called at the beginning of the provider lifecycle, when
// Terraform sends to the provider the values the user specified in the
// provider configuration block. These are supplied in the
// ConfigureProviderRequest argument.
// Values from provider configuration are often used to initialise an
// API client, which should be stored on the struct implementing the
// Provider interface.
Configure(context.Context, ConfigureProviderRequest, *ConfigureProviderResponse)
// GetResources returns a mapping of resource names to type
// implementations.
//
// Conventionally, resource names should each include a prefix of the
// provider name and an underscore. For example, a provider named
// "examplecloud" with resources "thing" and "widget" should use
// "examplecloud_thing" and "examplecloud_widget" as resource names.
GetResources(context.Context) (map[string]ResourceType, diag.Diagnostics)
// GetDataSources returns a mapping of data source name to types
// implementations.
//
// Conventionally, data source names should each include a prefix of the
// provider name and an underscore. For example, a provider named
// "examplecloud" with data sources "thing" and "widget" should use
// "examplecloud_thing" and "examplecloud_widget" as data source names.
GetDataSources(context.Context) (map[string]DataSourceType, diag.Diagnostics)
}
// ProviderWithProviderMeta is a provider with a provider meta schema.
// This functionality is currently experimental and subject to change or break
// without warning; it should only be used by providers that are collaborating
// on its use with the Terraform team.
type ProviderWithProviderMeta interface {
Provider
// GetMetaSchema returns the provider meta schema.
GetMetaSchema(context.Context) (Schema, diag.Diagnostics)
}