providerserver

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2023 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package providerserver provides testsdk handling of serving a provider.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DynamicValueToValue

func DynamicValueToValue(schema *tfprotov6.Schema, dynamicValue *tfprotov6.DynamicValue) (tftypes.Value, *tfprotov6.Diagnostic)

func NewProviderServer

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

NewProviderServer returns a lightweight protocol version 6 provider server for consumption with ProtoV6ProviderFactories.

func NewProviderServerWithError

func NewProviderServerWithError(p provider.Provider, err error) func() (tfprotov6.ProviderServer, error)

NewProviderServerWithError returns a lightweight protocol version 6 provider server and an associated error for consumption with ProtoV6ProviderFactories.

func ProviderDataSource

func ProviderDataSource(p provider.Provider, typeName string) (datasource.DataSource, *tfprotov6.Diagnostic)

func ProviderResource

func ProviderResource(p provider.Provider, typeName string) (resource.Resource, *tfprotov6.Diagnostic)

func SchemaAttributeAtPath

func SchemaAttributeAtPath(schema *tfprotov6.Schema, path *tftypes.AttributePath) *tfprotov6.SchemaAttribute

func ValuetoDynamicValue

func ValuetoDynamicValue(schema *tfprotov6.Schema, value tftypes.Value) (*tfprotov6.DynamicValue, *tfprotov6.Diagnostic)

Types

type ProviderServer

type ProviderServer struct {
	Provider provider.Provider
}

ProviderServer is a lightweight protocol version 6 provider server which is assumed to be well-behaved, e.g. does not return gRPC errors.

This implementation intends to reduce the heaviest parts of terraform-plugin-go based provider development:

  • Converting *tfprotov6.DynamicValue to tftypes.Value using schema
  • Splitting ApplyResourceChange into Create/Update/Delete calls
  • Set PlanResourceChange null config values of Computed attributes to unknown
  • Roundtrip UpgradeResourceState with equal schema version

By default, the following data is copied automatically:

  • ApplyResourceChange (create): req.Config -> resp.NewState
  • ApplyResourceChange (delete): req.PlannedState -> resp.NewState
  • ApplyResourceChange (update): req.PlannedState -> resp.NewState
  • PlanResourceChange: req.ProposedNewState -> resp.PlannedState
  • ReadDataSource: req.Config -> resp.State
  • ReadResource: req.CurrentState -> resp.NewState

func (ProviderServer) ReadResource

func (ProviderServer) StopProvider

Jump to

Keyboard shortcuts

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