Documentation
¶
Overview ¶
Package framework provides the terraform-plugin-framework flavour of the TencentCloud provider.
This package coexists with the SDKv2-based `tencentcloud.Provider()` inside the same provider binary via tf5muxserver. Directory layout: framework entry-points (provider, registry, tests) live under `tencentcloud/framework/`, while every business reference (resource, data source, function, ephemeral, list, action) is co-located with the SDKv2 implementations under `tencentcloud/services/<product>/`:
tencentcloud/
├── framework/ # this package: framework entry only
│ ├── provider.go # Provider Schema/Configure (this file)
│ ├── registry.go # 6-type aggregator
│ ├── acctest/ # ProtoV5 test factories
│ └── internal/ # framework-only helpers
└── services/
├── common/ # cross-product / provider-meta references
│ ├── data_source_tc_provider_runtime.go
│ ├── resource_tc_local_note.go
│ ├── function_tc_parse_resource_id.go
│ ├── ephemeral_tc_temp_credential.go
│ └── list_tc_region.go
├── cvm/ # CVM product (SDKv2 + framework mixed)
│ ├── resource_tc_instance.go # SDKv2
│ └── action_tc_cvm_reboot_instance.go # framework
└── <product>/ # other products follow the same pattern
Design notes:
- Credentials, SDK client, UA and retry are constructed exclusively by the SDKv2 provider; this provider reuses the same *connectivity.TencentCloudClient via sharedmeta.GetSharedMeta().
- Schema fields must mirror SDKv2 (same names, same semantics, same nesting). Otherwise mux will reject user-written fields when merging the two schemas.
- Resources/DataSources/Functions/EphemeralResources/ListResources/ Actions are gathered by aggregator functions in registry.go, which imports product-level packages directly from `tencentcloud/services/`.
registry.go is the central, SDKv2-style manifest of every terraform-plugin-framework reference shipped by this provider.
Layout mirrors tencentcloud/provider.go's ResourcesMap / DataSourcesMap: each framework reference type has its own append-only block of one entry per line. To add a new reference, edit ONLY this file by adding the corresponding services subpackage import (if not already present) and a single new entry in the matching block. No edit to provider.go is required.
Index ¶
- func NewProvider(primary *sdk_schema.Provider) provider.ProviderWithMetaSchema
- type Provider
- func (p *Provider) Actions(_ context.Context) []func() action.Action
- func (p *Provider) Configure(ctx context.Context, req provider.ConfigureRequest, ...)
- func (p *Provider) DataSources(_ context.Context) []func() datasource.DataSource
- func (p *Provider) EphemeralResources(_ context.Context) []func() ephemeral.EphemeralResource
- func (p *Provider) Functions(_ context.Context) []func() function.Function
- func (p *Provider) GenerateResourceConfig(context.Context, any) (any, error)
- func (p *Provider) ListResources(_ context.Context) []func() list.ListResource
- func (p *Provider) MetaSchema(_ context.Context, _ provider.MetaSchemaRequest, ...)
- func (p *Provider) Metadata(_ context.Context, _ provider.MetadataRequest, resp *provider.MetadataResponse)
- func (p *Provider) Resources(_ context.Context) []func() resource.Resource
- func (p *Provider) Schema(_ context.Context, _ provider.SchemaRequest, resp *provider.SchemaResponse)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewProvider ¶
func NewProvider(primary *sdk_schema.Provider) provider.ProviderWithMetaSchema
NewProvider constructs a framework provider instance to be registered as a secondary server inside mux. The primary parameter is the SDKv2 provider instance and is currently used only for metadata (such as version reflection); the framework provider does not invoke any runtime logic of the SDKv2 provider.
Types ¶
type Provider ¶
type Provider struct {
Version string
Primary *sdk_schema.Provider
}
Provider is the terraform-plugin-framework Provider implementation.
func (*Provider) Actions ¶
Actions aggregates every framework-side action. Implementations live in tencentcloud/services/<product>/ packages (for example, `services/cvm/action_tc_cvm_reboot_instance.go`) and are gathered by frameworkActions() in registry.go.
func (*Provider) Configure ¶
func (p *Provider) Configure(ctx context.Context, req provider.ConfigureRequest, resp *provider.ConfigureResponse)
Configure reuses the *connectivity.TencentCloudClient that SDKv2 has already constructed.
Key constraints:
- Credentials are never re-parsed here; credential logic must live in the single SDKv2 providerConfigure function.
- Inside mux, SDKv2 is Configure-d before framework (see registration order in main.go); sharedmeta.GetSharedMeta() should therefore return non-nil at this point.
- As a defensive measure, nil only adds an Error diagnostic instead of panicking, to make troubleshooting easier.