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.
func (*Provider) DataSources ¶
func (p *Provider) DataSources(_ context.Context) []func() datasource.DataSource
DataSources aggregates every framework-side data source.
func (*Provider) EphemeralResources ¶
func (p *Provider) EphemeralResources(_ context.Context) []func() ephemeral.EphemeralResource
EphemeralResources aggregates every framework-side ephemeral resource.
func (*Provider) GenerateResourceConfig ¶
GenerateResourceConfig is required by the framework interface but is not currently part of any configuration-generation flow.
func (*Provider) ListResources ¶
func (p *Provider) ListResources(_ context.Context) []func() list.ListResource
ListResources aggregates every framework-side list resource.
func (*Provider) MetaSchema ¶
func (p *Provider) MetaSchema(_ context.Context, _ provider.MetaSchemaRequest, resp *provider.MetaSchemaResponse)
MetaSchema MUST mirror SDKv2 exactly. The SDKv2 provider in tencentcloud/provider.go does NOT define a ProviderMetaSchemaFunc, which means SDKv2 reports an empty (zero-attribute) provider meta schema to the protocol. tf5muxserver compares the meta schema across underlying providers, so framework MUST also report an empty schema. Any attribute declared here that is not declared in SDKv2 will fail provider startup with "Invalid Provider Server Combination".
func (*Provider) Metadata ¶
func (p *Provider) Metadata(_ context.Context, _ provider.MetadataRequest, resp *provider.MetadataResponse)
Metadata exposes the provider's type name and version, used by the framework runtime for identification.
func (*Provider) Resources ¶
Resources aggregates every framework-side resource. The concrete entries are gathered by frameworkResources() in tencentcloud/framework/registry.go, which imports factories directly from `tencentcloud/services/<product>/` (e.g. `services/common/` for cross-product references).
func (*Provider) Schema ¶
func (p *Provider) Schema(_ context.Context, _ provider.SchemaRequest, resp *provider.SchemaResponse)
Schema mirrors the SDKv2 provider's field set byte-for-byte.
Key principles:
- Field names, types, Required/Optional, Sensitive flags and Description strings MUST match SDKv2 (tencentcloud/provider.go) exactly. tf5muxserver compares the protocol-level schema across underlying providers; any divergence (including a single character in Description) will fail provider startup with "Invalid Provider Server Combination".
- SDKv2's TypeSet/TypeList with MaxItems=1 is equivalent to a nested block at the protocol v5 layer, so we use SetNestedBlock / ListNestedBlock here, not nested attributes.
- The framework side does not consume any of these fields at runtime; credential parsing lives exclusively in the SDKv2 providerConfigure. This Schema only exists to satisfy mux's schema-consistency invariant.
- SDKv2 ConflictsWith / ValidateFunc / DefaultFunc are NOT serialized into the protocol schema, so they are intentionally not mirrored here. Only attributes that are part of the wire schema are mirrored.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package frameworkacctest provides ProtoV5ProviderFactories used by framework resource / data source acceptance tests.
|
Package frameworkacctest provides ProtoV5ProviderFactories used by framework resource / data source acceptance tests. |
|
internal
|
|
|
helper
Package helper is the shared utility package for resources/data sources on the terraform-plugin-framework side.
|
Package helper is the shared utility package for resources/data sources on the terraform-plugin-framework side. |