fwprovider

package
v1.20.1-0...-09b9789 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 8, 2025 License: MPL-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Copyright (c) HashiCorp, Inc. SPDX-License-Identifier: MPL-2.0

Copyright (c) HashiCorp, Inc. SPDX-License-Identifier: MPL-2.0

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

New is a helper function to simplify provider server and testing implementation.

func NewGoogleProviderConfigPluginFrameworkDataSource

func NewGoogleProviderConfigPluginFrameworkDataSource() datasource.DataSource

Types

type FrameworkProvider

type FrameworkProvider struct {
	Version string
	Primary *sdk_schema.Provider
}

FrameworkProvider is the provider implementation.

func (*FrameworkProvider) Configure

Configure prepares the metadata/'meta' required for data sources and resources to function. Configuration logic implemented here should take user inputs and use them to populate a struct with that necessary metadata, e.g. default project value, configured client, etc. That prepared 'meta' struct is then returned in the response, and that value will later be supplied to all resources/data sources when they need to configure themselves.

func (*FrameworkProvider) DataSources

func (p *FrameworkProvider) DataSources(_ context.Context) []func() datasource.DataSource

DataSources defines the data sources implemented in the provider.

func (*FrameworkProvider) EphemeralResources

func (p *FrameworkProvider) EphemeralResources(_ context.Context) []func() ephemeral.EphemeralResource

EphemeralResources defines the resources that are of ephemeral type implemented in the provider.

func (*FrameworkProvider) Functions

func (p *FrameworkProvider) Functions(_ context.Context) []func() function.Function

Functions defines the provider functions implemented in the provider.

func (*FrameworkProvider) MetaSchema

MetaSchema returns the provider meta schema.

func (*FrameworkProvider) Metadata

Metadata returns - the provider type name : this controls how "google" is present at the start of all resource type names - the provider version : this is currently unused by Terraform core

func (*FrameworkProvider) Resources

func (p *FrameworkProvider) Resources(_ context.Context) []func() resource.Resource

Resources defines the resources implemented in the provider.

func (*FrameworkProvider) Schema

Schema defines the provider-level schema for configuration data. See: https://developer.hashicorp.com/terraform/plugin/framework/migrating/mux "The schema and configuration handling must exactly match between all underlying providers of the mux server" This schema matches the schema implemented with SDKv2 in google/provider/provider.go

type GoogleProviderConfigPluginFrameworkDataSource

type GoogleProviderConfigPluginFrameworkDataSource struct {
	// contains filtered or unexported fields
}

func (*GoogleProviderConfigPluginFrameworkDataSource) Configure

func (*GoogleProviderConfigPluginFrameworkDataSource) Metadata

func (*GoogleProviderConfigPluginFrameworkDataSource) Read

func (*GoogleProviderConfigPluginFrameworkDataSource) Schema

type GoogleProviderConfigPluginFrameworkModel

type GoogleProviderConfigPluginFrameworkModel struct {
	Credentials                        types.String `tfsdk:"credentials"`
	AccessToken                        types.String `tfsdk:"access_token"`
	ImpersonateServiceAccount          types.String `tfsdk:"impersonate_service_account"`
	ImpersonateServiceAccountDelegates types.List   `tfsdk:"impersonate_service_account_delegates"`
	Project                            types.String `tfsdk:"project"`
	BillingProject                     types.String `tfsdk:"billing_project"`
	Region                             types.String `tfsdk:"region"`
	Zone                               types.String `tfsdk:"zone"`
	Scopes                             types.List   `tfsdk:"scopes"`
	//	omit Batching
	UserProjectOverride                       types.Bool   `tfsdk:"user_project_override"`
	RequestTimeout                            types.String `tfsdk:"request_timeout"`
	RequestReason                             types.String `tfsdk:"request_reason"`
	UniverseDomain                            types.String `tfsdk:"universe_domain"`
	DefaultLabels                             types.Map    `tfsdk:"default_labels"`
	AddTerraformAttributionLabel              types.Bool   `tfsdk:"add_terraform_attribution_label"`
	TerraformAttributionLabelAdditionStrategy types.String `tfsdk:"terraform_attribution_label_addition_strategy"`
}

GoogleProviderConfigPluginFrameworkModel describes the data source and matches the schema. Its fields match those in a Config struct (google/transport/config.go) but uses a different type system.

  • In the original Config struct old SDK/Go primitives types are used, e.g. `string`
  • Here in the GoogleProviderConfigPluginFrameworkModel struct we need to use the terraform-plugin-framework/types type system, e.g. `types.String`
  • This is needed because the PF type system is 'baked into' how we define schemas. The schema will expect a nullable type.
  • See terraform-plugin-framework/datasource/schema#StringAttribute's CustomType: https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework@v1.7.0/datasource/schema#StringAttribute
  • Due to the different type systems of Config versus GoogleProviderConfigPluginFrameworkModel struct, we need to convert from primitive types to terraform-plugin-framework/types when we populate GoogleProviderConfigPluginFrameworkModel structs with data in this data source's Read method.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL