Documentation ¶
Index ¶
- Constants
- func Added(oldValues, newValues []string) []string
- func DiagError(summary string, err error, diags diag.Diagnostics) diag.Diagnostics
- func Filter[T any](slice []T, filterFunc func(T) bool) []T
- func GetChangeWithParse[T any](d *schema.ResourceData, key string, parseFunc func(any) T) (T, T, bool)
- func Map[T, U any](slice []T, mapFunc func(T) U) []U
- func MustGetChange[T any](d *schema.ResourceData, key string) (T, T, bool)
- func MustResourceDataCollectionToSlice[T any](d *schema.ResourceData, fieldName string) []T
- func MustSchemaCollectionToSlice[T any](listOrSet any) []T
- func MustSliceAs[T any](slice []any) []T
- func MustUnmarshalAs[T, U any](toConvert U) T
- func MustValueAs[T any](val any) T
- func Removed(oldValues, newValues []string) []string
- func SliceToStringIndicatorsMap[T any](slice []T) map[string]T
- func SlicesDiff[T any](oldValues, newValues []T) ([]T, []T)
- func SupressDiffIfExists(k, old, new string, d *schema.ResourceData) bool
- func UnmarshalAs[T, U any](toConvert U) (T, error)
Constants ¶
const (
ExpectResourceNotFound = "expectNotFoundResource"
)
Variables ¶
This section is empty.
Functions ¶
func DiagError ¶
func DiagError(summary string, err error, diags diag.Diagnostics) diag.Diagnostics
DiagError collects errors and appends diagnostics with diagnostic of err
func Filter ¶
Filter takes 2 arguments: 1. A slice of generic type T 2. A function that excepts an argument of generic type T and returns a boolean The Filter function than applies the filterFunc to each element of the slice and returns a sub-slice which contains all element x where filterFunc(x) == true
func GetChangeWithParse ¶
func GetChangeWithParse[T any](d *schema.ResourceData, key string, parseFunc func(any) T) (T, T, bool)
GetChangeWithParse checks if there has been any changes made to the value saved under the given key in the resourceData object if so, the functon applies the given parse function to the old and new values and returns the parsing results the function also returns a boolean which indicates weather a change has been made or not
func Map ¶
func Map[T, U any](slice []T, mapFunc func(T) U) []U
Map takes 2 arguments: 1. A slice of generic type T 2. A function that excepts an argument of generic type T and returns a value of generic type U The Map function than applies the mapFunc to each element of the slice and returns a slice of the retruned values from the mapFunc
func MustGetChange ¶
func MustGetChange[T any](d *schema.ResourceData, key string) (T, T, bool)
GetChangeWithParse checks if there has been any changes made to the value saved under the given key in the resourceData object if so, the functon converts the the old and new values to the desired type note that if the conversion fails the function will panic!
func MustResourceDataCollectionToSlice ¶
func MustResourceDataCollectionToSlice[T any](d *schema.ResourceData, fieldName string) []T
MustResourceDataCollectionToSlice takes a ResourceData object and a fieldName the function tries to retrieve the field's value and expects it to be of type schema.TypeSet or schema.TypeList (otherwise it will panic!) this function then converts the set/list to a slice of the desired type
func MustSchemaCollectionToSlice ¶
MustSchemaCollectionToSlice converts the argument to a slice of the desired type The argument must be of type schema.TypeSet or schema.TypeList otherwise, the function will panic
func MustSliceAs ¶
MustSliceAs takes a slice as an argument and converts all it's members to the desired type T
func MustUnmarshalAs ¶
func MustUnmarshalAs[T, U any](toConvert U) T
MustUnmarshalAs marshals the argument and than unmarshals it to the desired type ignores error if marshal/unmarshal fails (prints the error and returns the empty value of the desired type)
func MustValueAs ¶
MustValueAs converts a the given argument to the desired type note that this conversion is not safe and may panic
func SliceToStringIndicatorsMap ¶
SliceToStringIndicatorsMap excepts a slice of generice type T The function returns a map from a string representation of each value in the slice to the value itself for example: [1, 2, 3] ==> {"1": 1, "2": 2, "3": 3}
func SlicesDiff ¶
func SlicesDiff[T any](oldValues, newValues []T) ([]T, []T)
SlicesDiff excepts to slices which represents old and new values THe function returns: 1. a slice of all values that exist in the new and not in the old slice (a.k.a "added") 2. a slice of all values that exist in the old and not in the new slice (a.k.a "removed")
func SupressDiffIfExists ¶
func SupressDiffIfExists(k, old, new string, d *schema.ResourceData) bool
SupressDiffIfExists shows diff only if resource is new
func UnmarshalAs ¶
UnmarshalAs marshals the argument and than unmarshals it to the desired type returns error upon failure
Types ¶
This section is empty.