cty

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CtyMarshalableListVal

func CtyMarshalableListVal[T CtyMarshalable](items []T) cty.Value

CtyMarshalableListVal turns a slice of CtyMarshalable items into a cty-compatible "list-value".

func CtyMarshalableMapVal

func CtyMarshalableMapVal[T CtyMarshalable](m map[string]T) cty.Value

CtyMarshalableMapVal turns a map of CtyMarshalable slices into a cty-compatible "map-value".

func CtyMarshalableSliceMapVal

func CtyMarshalableSliceMapVal[T CtyMarshalable](m map[string][]T) cty.Value

CtyMarshalableSliceMapVal turns a map of CtyMarshalable slices into a cty-compatible "map-value".

func ListVal

func ListVal[F func(T) cty.Value, T any](f F, items ...T) cty.Value

ListVal turns a slice of items, which can be transformed to a cty.Value by way of the function f, into a cty-compatible "list-value".

func MapVal

func MapVal[F func(T) cty.Value, T any](f F, m map[string]T) cty.Value

MapVal turns a map of items, which can be transformed to a cty.Value by way of the function f, into a cty-compatible "map-value".

func StringSliceListVal

func StringSliceListVal(items []string) cty.Value

StringSliceListVal turns a slice of strings into a cty-compatible "list-value".

func StringSliceMapVal

func StringSliceMapVal(m map[string][]string) cty.Value

StringSliceMapVal turns a map of string-slices into a cty-compatible "map-value".

func Stringify

func Stringify(val cty.Value) string

Stringify attempts to return a string representation of val that corresponds as closely as possible Go's fmt.Stringer return value. NOTE the "map" prefix for maps is omitted. NOTE elements are separated by a space; no commas are used.

Types

type CtyMarshalable

type CtyMarshalable interface {
	CtyValue() cty.Value
}

CtyMarshalable implementors are expected to provide support for a cty-encoding.

type CtyTypeable

type CtyTypeable interface {
	CtyMarshalable
	CtyType() cty.Type
}

CtyTypeable implementors are expected to provide a cty.Type for an object to ve used with gocty.ToCtyValue, see also https://github.com/zclconf/go-cty/blob/main/docs/gocty.md

type CtyValueMap

type CtyValueMap = map[string]cty.Value

CtyValueMap is a simple type alias.

func AssignToMapVal

func AssignToMapVal(mv CtyValueMap, mapValKey, attrKey string,
	attrVal cty.Value, f MapValToCtyValueFunc) CtyValueMap

AssignToMapVal assigns some attribute value to an attribute key in a value map either directly or under an optional map-key. If mv is not nil, attrVal's assignment is itself a MapVal, which is transformed to a cty.Value by f, typically either cty.ObjectVal or cty.MapVal.

A pseudo-code expression for this operation is: "mv[mapValKey] += f(mv[mapValKey] with mv[mapValKey][attrKey] = attrVal)"

If mv[mapValKey] is a map, then cty requires the attrVal to be "type-homogenous", see https://github.com/zclconf/go-cty/blob/main/docs/types.md#ctymap-types If mv[mapValKey] is an object, then attrVal can be of any type.

If the value map mv is nil, then a new MapVal is created and the return value will be different from mv. If mapValKey is empty, then attrVal is simply assigned to mv[attrKey].

type MapValToCtyValueFunc

type MapValToCtyValueFunc func(CtyValueMap) cty.Value

MapValToCtyValueFunc ...

type UInt16Wrapper

type UInt16Wrapper uint16

UInt16Wrapper is a convenience wrapper for the uint16 type.

func (UInt16Wrapper) CtyValue

func (w UInt16Wrapper) CtyValue() cty.Value

implements the CtyMarshaler interface.

Directories

Path Synopsis
function
lib

Jump to

Keyboard shortcuts

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