tf

package
v5.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2023 License: MPL-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package tf is where provider functions were dropped

Index

Constants

This section is empty.

Variables

View Source
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")
)

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 ComposeDiffSuppress

func ComposeDiffSuppress(fncs ...schema.SchemaDiffSuppressFunc) schema.SchemaDiffSuppressFunc

ComposeDiffSuppress aggregates all given schema.SchemaDiffSuppressFunc into one Aggregated function returns true if any of the functions returns true

func ConvertListOfIntToInt64

func ConvertListOfIntToInt64(ints []interface{}) []int64

ConvertListOfIntToInt64 casts slice of any type into slice of int64

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 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 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 GetInt64Value

func GetInt64Value(key string, rd ResourceDataFetcher) (int64, error)

GetInt64Value fetches value with given key from ResourceData object and attempts type cast to int64

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 GetMapValue

func GetMapValue(key string, rd ResourceDataFetcher) (map[string]interface{}, error)

GetMapValue fetches value with given key from ResourceData object and attempts type cast to map[string]interface{}

if value is not present on provided resource, ErrNotFound is returned if casting is not successful, ErrInvalidType is returned

func GetSchemaFieldNameFromPath

func GetSchemaFieldNameFromPath(path cty.Path) (string, error)

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

func MaxDuration(x, y time.Duration) time.Duration

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

func SetToStringSlice(s *schema.Set) []string

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 ValidateMapMinimalLength

func ValidateMapMinimalLength(min int) schema.SchemaValidateDiagFunc

ValidateMapMinimalLength validates the map by checking if it contains at least provided number of entries

func ValidateNetwork

func ValidateNetwork(i interface{}, _ cty.Path) diag.Diagnostics

ValidateNetwork defines network validation logic

func ValidateRuleFormat

func ValidateRuleFormat(v interface{}, _ cty.Path) diag.Diagnostics

ValidateRuleFormat checks if value is a valid rule format of form vYYYY-MM-DD Empty string ("") is considered valid as well

func ValidateRuleFormatAcceptLatest

func ValidateRuleFormatAcceptLatest(v interface{}, _ cty.Path) diag.Diagnostics

ValidateRuleFormatAcceptLatest checks if value is a valid rule format of form vYYYY-MM-DD or 'latest' Empty string ("") is considered valid as well

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 RawConfig

type RawConfig struct {
	// contains filtered or unexported fields
}

RawConfig is used to query attributes from the raw config.

func NewRawConfig

func NewRawConfig(data *schema.ResourceData) *RawConfig

NewRawConfig creates a new RawConfig which uses the raw config retrieved from data.

func (RawConfig) GetOk

func (rc RawConfig) GetOk(key string) (any, bool)

GetOk returns the data for the given key and whether or not the key was set to a non-zero value.

type ResourceDataFetcher

type ResourceDataFetcher interface {
	GetOk(string) (interface{}, bool)
}

ResourceDataFetcher ...

Directories

Path Synopsis
Package validators contains custom terraform schema validators
Package validators contains custom terraform schema validators

Jump to

Keyboard shortcuts

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