util

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ValidateIsJSON = WrapValidateFunc(func(value interface{}, key string) error {
	var a interface{}
	if err := json.Unmarshal([]byte(value.(string)), &a); err != nil {
		return fmt.Errorf("the value of the field '%s' must be JSON string: %w", key, err)
	}
	return nil
})
View Source
var ValidateIsMapJSON = WrapValidateFunc(func(value interface{}, key string) error {
	var a interface{}
	if err := json.Unmarshal([]byte(value.(string)), &a); err != nil {
		return fmt.Errorf("the value of the field '%s' must be JSON string: %w", key, err)
	}
	if _, ok := a.(map[string]interface{}); !ok {
		return errors.New("the value of the field '" + key + "' must be JSON string of map")
	}
	return nil
})

Functions

func GenStateFunc

func GenStateFunc(keys ...string) schema.StateContextFunc

func HandleGetResourceError

func HandleGetResourceError(
	d *schema.ResourceData, resp *http.Response, err error, codes ...int,
) error

func RenameKey

func RenameKey(data map[string]interface{}, oldKey, newKey string) (interface{}, bool)

func SchemaDiffSuppressJSONString

func SchemaDiffSuppressJSONString(k, oldV, newV string, d *schema.ResourceData) bool

func SetDefaultValue

func SetDefaultValue(data map[string]interface{}, key string, value interface{})

func WrapValidateFunc

func WrapValidateFunc(f func(v interface{}, k string) error) schema.SchemaValidateFunc

Types

This section is empty.

Jump to

Keyboard shortcuts

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