providerserver

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2022 License: MPL-2.0 Imports: 11 Imported by: 608

Documentation

Overview

Package providerserver implements functionality for serving a provider, such as directly starting a server in a production binary and conversion functions for testing.

For production usage, call the Serve function from binary startup, such as from the provider codebase main package. If multiplexing the provider server via terraform-plugin-mux functionality, use the NewProtocol* functions and call the Serve function from that Go module. For testing usage, call the NewProtocol* functions.

All functionality in this package requires the provider.Provider type, which contains the provider implementation including all managed resources and data sources.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewProtocol5 added in v0.9.0

func NewProtocol5(p provider.Provider) func() tfprotov5.ProviderServer

NewProtocol5 returns a protocol version 5 ProviderServer implementation based on the given Provider and suitable for usage with the github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.Serve() function and various terraform-plugin-mux functions.

func NewProtocol5WithError added in v0.9.0

func NewProtocol5WithError(p provider.Provider) func() (tfprotov5.ProviderServer, error)

NewProtocol5WithError returns a protocol version 5 ProviderServer implementation based on the given Provider and suitable for usage with github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource.TestCase.ProtoV5ProviderFactories.

The error return is not currently used, but it may be in the future.

func NewProtocol6

func NewProtocol6(p provider.Provider) func() tfprotov6.ProviderServer

NewProtocol6 returns a protocol version 6 ProviderServer implementation based on the given Provider and suitable for usage with the github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.Serve() function and various terraform-plugin-mux functions.

func NewProtocol6WithError

func NewProtocol6WithError(p provider.Provider) func() (tfprotov6.ProviderServer, error)

NewProtocol6WithError returns a protocol version 6 ProviderServer implementation based on the given Provider and suitable for usage with github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource.TestCase.ProtoV6ProviderFactories.

The error return is not currently used, but it may be in the future.

func Serve

func Serve(ctx context.Context, providerFunc func() provider.Provider, opts ServeOpts) error

Serve serves a provider, blocking until the context is canceled.

Types

type ServeOpts

type ServeOpts struct {
	// Address is the full address of the provider. Full address form has three
	// parts separated by forward slashes (/): Hostname, namespace, and
	// provider type ("name").
	//
	// For example: registry.terraform.io/hashicorp/random.
	Address string

	// Debug runs the provider in a mode acceptable for debugging and testing
	// processes, such as delve, by managing the process lifecycle. Information
	// needed for Terraform CLI to connect to the provider is output to stdout.
	// os.Interrupt (Ctrl-c) can be used to stop the provider.
	Debug bool

	// ProtocolVersion is the protocol version that should be used when serving
	// the provider. Either protocol version 5 or protocol version 6 can be
	// used. Defaults to protocol version 6.
	//
	// Protocol version 5 has the following functionality limitations, which
	// will raise an error during the GetProviderSchema or other RPCs:
	//
	//     - tfsdk.Attribute cannot use Attributes field (nested attributes).
	//
	ProtocolVersion int
}

ServeOpts are options for serving the provider.

Jump to

Keyboard shortcuts

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