common

package
v0.0.0-...-ac83338 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2025 License: MPL-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package common contains some helpers we use across multiple major-version implementations of the provider protocol.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CtyValueAsJSON

func CtyValueAsJSON(v cty.Value, ty cty.Type) ([]byte, error)

func CtyValueAsMsgpack

func CtyValueAsMsgpack(v cty.Value, ty cty.Type) ([]byte, error)

func MapSeq

func MapSeq[FromV, ToV any](seq iter.Seq[FromV], f func(v FromV) ToV) iter.Seq[ToV]

MapSeq performs a systematic transformation of each item in seq, producing a new sequence of the same length based on the results.

(Hopefully there will be something like this in the Go standard library one day, at which point we should use it and remove this.)

func MapSeq2

func MapSeq2[FromK, FromV, ToK, ToV any](seq iter.Seq2[FromK, FromV], f func(k FromK, v FromV) (ToK, ToV)) iter.Seq2[ToK, ToV]

MapSeq performs a systematic transformation of each item in seq, producing a new sequence of the same length based on the results.

(Hopefully there will be something like this in the Go standard library one day, at which point we should use it and remove this.)

func MapSeq2ToSeq

func MapSeq2ToSeq[FromK, FromV, ToV any](seq iter.Seq2[FromK, FromV], f func(k FromK, v FromV) ToV) iter.Seq[ToV]

MapSeq2ToSeq is similar to MapSeq and MapSeq2 but allows reducing from iter.Seq2 to iter.Seq during transformation.

func MapSeqToSeq2

func MapSeqToSeq2[FromV, ToK, ToV any](seq iter.Seq[FromV], f func(v FromV) (ToK, ToV)) iter.Seq2[ToK, ToV]

MapSeqToSeq2 is similar to MapSeq and MapSeq2 but allows expanding from iter.Seq to iter.Seq2 during transformation.

Types

type CtyTypeJSON

type CtyTypeJSON []byte

CtyTypeJSON makes a byte array containing a standard JSON serialization of cty.Type implement [providerschema.TypeConstraint].

func (CtyTypeJSON) AsCtyType

func (c CtyTypeJSON) AsCtyType() (cty.Type, error)

AsCtyType implements providerschema.TypeConstraint.

type CtyValueJSON

type CtyValueJSON []byte

func (CtyValueJSON) AsCtyValue

func (c CtyValueJSON) AsCtyValue(withType cty.Type) (cty.Value, error)

type CtyValueMsgpack

type CtyValueMsgpack []byte

func (CtyValueMsgpack) AsCtyValue

func (c CtyValueMsgpack) AsCtyValue(withType cty.Type) (cty.Value, error)

type Sealed

type Sealed interface {
	// contains filtered or unexported methods
}

Sealed is an interface that we embed in various other interface types to ensure that they can't be implemented by types outside of this module, because we need to be able to grow those interfaces over time as the underlying protocols evolve.

This module uses interfaces only for dynamic dispatch over a fixed set of implementations covering different versions of the plugin protocol, and not to support third-party implementations.

type SealedImpl

type SealedImpl struct{}

SealedImpl is a zero-sized type that implements Sealed, intended to be embedded into other struct types to make them implement that interface even though they can't directly implement the "sealed()" method.

Jump to

Keyboard shortcuts

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