utils

package
v0.0.30 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2025 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Addr added in v0.0.29

func Addr[T any](t T) *T

Addr returns the address of t.

func GenerateUpdateTimestamp added in v0.0.23

func GenerateUpdateTimestamp() basetypes.StringValue

func IsKnown added in v0.0.11

func IsKnown(value attr.Value) bool

IsKnown returns true if an attribute value is known and not null.

func ListIDsToModify

func ListIDsToModify(
	ctx context.Context,
	plan, state types.List,
) (idsToAdd []string, idsToRemove []string, diags diag.Diagnostics)

ListIDsToModify takes a list of unique IDs from plan and state and returns the IDs to add and remove to get from the state to the plan. idsToAdd is the slice of IDs that are in the plan but not in the state. idsToRemove is the slice of IDs that are in the state but not in the plan. useful for resources with HostGroups, RuleGroups, etc.

func ListTypeAs added in v0.0.11

func ListTypeAs[T any](
	ctx context.Context,
	list types.List,
	diags *diag.Diagnostics,
) []T

ListTypeAs converts a types.List into a known []T.

func MapTypeAs added in v0.0.29

func MapTypeAs[T any](
	ctx context.Context,
	mapIn types.Map,
	diags *diag.Diagnostics,
) map[string]T

MapTypeAs converts a types.Map into a known map[string]T.

func MarkdownDescription added in v0.0.23

func MarkdownDescription(section string, description string, apiScopes []scopes.Scope) string

MarkdownDescription generates a markdown description that works for generating terraform docs.

func MissingElements added in v0.0.26

func MissingElements(a, b []string) []string

MissingElements checks if any elements in slice `a` are missing from slice `b`. It returns a slice containing the missing elements.

func PancicPrettyPrint added in v0.0.20

func PancicPrettyPrint(v interface{})

PancicPrettyPrint converts the interface into a json string and panics.

func SetIDsToModify

func SetIDsToModify(
	ctx context.Context,
	plan, state types.Set,
) (idsToAdd []string, idsToRemove []string, diags diag.Diagnostics)

SetIDsToModify takes a set of IDs from plan and state and returns the IDs to add and remove to get from the state to the plan. idsToAdd is the slice of IDs that are in the plan but not in the state. idsToRemove is the slice of IDs that are in the state but not in the plan. useful for resources with HostGroups, RuleGroups, etc.

func SliceToListTypeObject added in v0.0.29

func SliceToListTypeObject[T any](
	ctx context.Context,
	elems []T,
	attrs map[string]attr.Type,
	diags *diag.Diagnostics,
) types.List

SliceToListTypeObject converts []T into types.List with an attr.Type of types.Object{}.

func SliceToListTypeString added in v0.0.29

func SliceToListTypeString(
	ctx context.Context,
	elems []string,
	diags *diag.Diagnostics,
) types.List

SliceToListTypeString converts []string into types.List with an attr.Type of types.String. Empty []string will result in an empty types.List.

func ValidateEmptyIDs added in v0.0.20

func ValidateEmptyIDs(ctx context.Context, checkSet types.Set, attrPath string) diag.Diagnostics

ValidateEmptyIDs checks if a set contains empty IDs. Returns a attribute error at path.

func ValidateEmptyIDsList added in v0.0.29

func ValidateEmptyIDsList(
	ctx context.Context,
	checkList types.Set,
	attrPath string,
) diag.Diagnostics

ValidateEmptyIDsList checks if a list contains empty IDs. Returns a attribute error at path.

Types

This section is empty.

Jump to

Keyboard shortcuts

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