Documentation ¶
Overview ¶
Package tools is where some legacy provider functions were dropped
Index ¶
- Constants
- Variables
- func AddPrefix(str, pre string) string
- func AggregateValidations(funcs ...schema.SchemaValidateDiagFunc) schema.SchemaValidateDiagFunc
- func BoolPtr(b bool) *bool
- func ContainsString(s []string, searchTerm string) bool
- func ConvertListOfIntToInt64(ints []interface{}) []int64
- func ConvertToString(data interface{}) (res string)
- func DiagWarningf(format string, a ...interface{}) diag.Diagnostics
- func DiagsWithErrors(d diag.Diagnostics, errs ...error) diag.Diagnostics
- func FieldPrefixSuppress(prefix string) schema.SchemaDiffSuppressFunc
- func FindStringValues(rd ResourceDataFetcher, keys ...string) []string
- func Float64Ptr(f float64) *float64
- func GetBoolValue(key string, rd ResourceDataFetcher) (bool, error)
- func GetExactlyOneOf(rd ResourceDataFetcher, keys []string) (foundKey string, value interface{}, err error)
- func GetFirstNotEmpty(values ...string) string
- func GetFloat32Value(key string, rd ResourceDataFetcher) (float32, error)
- func GetFloat64Value(key string, rd ResourceDataFetcher) (float64, error)
- func GetIntID(str, prefix string) (int, error)
- func GetIntValue(key string, rd ResourceDataFetcher) (int, error)
- func GetInterfaceArrayValue(key string, rd ResourceDataFetcher) ([]interface{}, error)
- func GetListValue(key string, rd ResourceDataFetcher) ([]interface{}, error)
- func GetMd5Sum(key interface{}) (string, error)
- func GetSHAString(rdata string) string
- func GetSchemaFieldNameFromPath(path cty.Path) (string, error)
- func GetSetValue(key string, rd ResourceDataFetcher) (*schema.Set, error)
- func GetStringValue(key string, rd ResourceDataFetcher) (string, error)
- func Int64Ptr(i int64) *int64
- func IntPtr(i int) *int
- func IsNotBlank(i interface{}, _ cty.Path) diag.Diagnostics
- func MaxDuration(x, y time.Duration) time.Duration
- func ParseDate(layout, value string) (time.Time, error)
- func ResetAttrs(d *schema.ResourceData, attributes ...string) error
- func ResolveKeyStringState(rd ResourceDataFetcher, key, fallbackKey string) (value string, err error)
- func RestoreOldValues(rd *schema.ResourceData, keys []string) error
- func SetAttrs(d *schema.ResourceData, AttributeValues map[string]interface{}) error
- func SetToStringSlice(s *schema.Set) []string
- func StateNetwork(i interface{}) string
- func StringPtr(s string) *string
- func ValidateEmail(val interface{}, _ cty.Path) diag.Diagnostics
- func ValidateJSON(val interface{}, _ cty.Path) diag.Diagnostics
- func ValidateNetwork(i interface{}, _ cty.Path) diag.Diagnostics
- func ValidateStringInSlice(valid []string) schema.SchemaValidateDiagFunc
- type ResourceDataFetcher
Constants ¶
const DateTimeFormat = "2006-01-02T15:04:05Z"
DateTimeFormat is the layout used across the provider.
Variables ¶
var ( // ErrInvalidType is returned when given value is of invalid type (i.e. different type than requested) ErrInvalidType = errors.New("value must be of the specified type") // ErrNotFound is returned when value is not present on schema ErrNotFound = errors.New("value not found") // ErrValueSet is returned when setting property value returned an error ErrValueSet = errors.New("setting property value") // ErrEmptyKey is returned when setting property value returned an error ErrEmptyKey = errors.New("provided key cannot be empty") // ErrEmptyPath is returned when path is empty ErrEmptyPath = errors.New("path cannot be empty") )
var ErrDateFormat = errors.New("unable to parse date")
ErrDateFormat is returned when there is an error parsing a string date
Functions ¶
func AggregateValidations ¶
func AggregateValidations(funcs ...schema.SchemaValidateDiagFunc) schema.SchemaValidateDiagFunc
AggregateValidations takes any number of schema.SchemaValidateDiagFunc and executes them one by one it returns a diagnostics object containing combined results of each validation function
func ContainsString ¶
ContainsString determines if the searched string appears in the array
func ConvertListOfIntToInt64 ¶ added in v2.2.0
func ConvertListOfIntToInt64(ints []interface{}) []int64
ConvertListOfIntToInt64 casts slice of any type into slice of int64
func ConvertToString ¶
func ConvertToString(data interface{}) (res string)
ConvertToString will convert different types to strings.
func DiagWarningf ¶
func DiagWarningf(format string, a ...interface{}) diag.Diagnostics
DiagWarningf creates a diag.Diagnostics with a single Warning level diag.Diagnostic entry
func DiagsWithErrors ¶
func DiagsWithErrors(d diag.Diagnostics, errs ...error) diag.Diagnostics
DiagsWithErrors appends several errors to a diag.Diagnostics
func FieldPrefixSuppress ¶
func FieldPrefixSuppress(prefix string) schema.SchemaDiffSuppressFunc
FieldPrefixSuppress returns schema.SchemaDiffSuppressFunc which verifies whether values are equal disregarding given prefix
func FindStringValues ¶
func FindStringValues(rd ResourceDataFetcher, keys ...string) []string
FindStringValues searches the ResourceData for the list of keys and returns the array of values
if the value does not exist it is skipped if the value cannot be cast to string it is skipped
func Float64Ptr ¶
Float64Ptr returns a pointer to a float64 passed as an argument
func GetBoolValue ¶
func GetBoolValue(key string, rd ResourceDataFetcher) (bool, error)
GetBoolValue fetches value with given key from ResourceData object and attempts type cast to bool
if value is not present on provided resource, ErrNotFound is returned if casting is not successful, ErrInvalidType is returned
func GetExactlyOneOf ¶
func GetExactlyOneOf(rd ResourceDataFetcher, keys []string) (foundKey string, value interface{}, err error)
GetExactlyOneOf extracts exactly one value with given keys from ResourceData object if multiple values are present the function returns first one found
func GetFirstNotEmpty ¶
GetFirstNotEmpty returns first not empty string
func GetFloat32Value ¶
func GetFloat32Value(key string, rd ResourceDataFetcher) (float32, error)
GetFloat32Value fetches value with given key from ResourceData object and attempts type cast to float64
if value is not present on provided resource, ErrNotFound is returned if casting is not successful, ErrInvalidType is returned
func GetFloat64Value ¶
func GetFloat64Value(key string, rd ResourceDataFetcher) (float64, error)
GetFloat64Value fetches value with given key from ResourceData object and attempts type cast to float64
if value is not present on provided resource, ErrNotFound is returned if casting is not successful, ErrInvalidType is returned
func GetIntValue ¶
func GetIntValue(key string, rd ResourceDataFetcher) (int, error)
GetIntValue fetches value with given key from ResourceData object and attempts type cast to int
if value is not present on provided resource, ErrNotFound is returned if casting is not successful, ErrInvalidType is returned
func GetInterfaceArrayValue ¶
func GetInterfaceArrayValue(key string, rd ResourceDataFetcher) ([]interface{}, error)
GetInterfaceArrayValue fetches value with given key from ResourceData object and attempts type cast to []interface{}
if value is not present on provided resource for key, ErrNotFound is returned if casting is not successful, ErrInvalidType is returned
func GetListValue ¶
func GetListValue(key string, rd ResourceDataFetcher) ([]interface{}, error)
GetListValue fetches value with given key from ResourceData object and attempts type cast to []interface{}
if value is not present on provided resource, ErrNotFound is returned if casting is not successful, ErrInvalidType is returned
func GetMd5Sum ¶
GetMd5Sum calculates md5Sum for any given interface{}. Passing a nil pointer to GetMd5Sum will panic, as they cannot be transmitted by gob.
func GetSHAString ¶
GetSHAString returns a sha1 from the string
func GetSchemaFieldNameFromPath ¶
GetSchemaFieldNameFromPath returns schema field name from given path
if len of path is zero it returns empty string and error
func GetSetValue ¶
func GetSetValue(key string, rd ResourceDataFetcher) (*schema.Set, error)
GetSetValue fetches value with given key from ResourceData object and attempts type cast to *schema.Set
if value is not present on provided resource, ErrNotFound is returned if casting is not successful, ErrInvalidType is returned
func GetStringValue ¶
func GetStringValue(key string, rd ResourceDataFetcher) (string, error)
GetStringValue fetches value with given key from ResourceData object and attempts type cast to string
if value is not present on provided resource for key, ErrNotFound is returned if casting is not successful, ErrInvalidType is returned
func IsNotBlank ¶
func IsNotBlank(i interface{}, _ cty.Path) diag.Diagnostics
IsNotBlank verifies whether given value is not blank and returns error if it is where "blank" means: - nil value - a collection with len == 0 in case the value is a map, array or slice - value equal to zero-value for given type (e.g. empty string)
func MaxDuration ¶
MaxDuration returns the larger of x or y.
func ResetAttrs ¶
func ResetAttrs(d *schema.ResourceData, attributes ...string) error
ResetAttrs resets (sets to nil) the provided set of attributes
func ResolveKeyStringState ¶
func ResolveKeyStringState(rd ResourceDataFetcher, key, fallbackKey string) (value string, err error)
ResolveKeyStringState fetches value with given key (or fallbackKey) from ResourceData object
func RestoreOldValues ¶
func RestoreOldValues(rd *schema.ResourceData, keys []string) error
RestoreOldValues reverts the value in schema of the given keys
func SetAttrs ¶
func SetAttrs(d *schema.ResourceData, AttributeValues map[string]interface{}) error
SetAttrs allows you to set many attributes of a schema.ResourceData in one call
func SetToStringSlice ¶
SetToStringSlice converts schema.Set to a slice of strings
func StateNetwork ¶
func StateNetwork(i interface{}) string
StateNetwork changes the value of the input before storing it in state
func ValidateEmail ¶
func ValidateEmail(val interface{}, _ cty.Path) diag.Diagnostics
ValidateEmail checks if value is a valid email
func ValidateJSON ¶
func ValidateJSON(val interface{}, _ cty.Path) diag.Diagnostics
ValidateJSON checks whether given value is a valid JSON object
func ValidateNetwork ¶
func ValidateNetwork(i interface{}, _ cty.Path) diag.Diagnostics
ValidateNetwork defines network validation logic
func ValidateStringInSlice ¶
func ValidateStringInSlice(valid []string) schema.SchemaValidateDiagFunc
ValidateStringInSlice returns schema.SchemaValidateDiagFunc which tests if the value is a string and if it matches given slice of valid strings
Types ¶
type ResourceDataFetcher ¶
ResourceDataFetcher ...