utils

package
v6.4.15 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: MPL-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultTimeout = 60 * time.Minute

Variables

This section is empty.

Functions

func CheckFileExists added in v6.3.2

func CheckFileExists(filePath string) bool

func CreateTransport

func CreateTransport() *http.Transport

CreateTransport - creates customizable transport for http clients

func DecodeInterfaceToStruct added in v6.4.5

func DecodeInterfaceToStruct(input, output interface{}) error

DecodeInterfaceToStruct can decode from interface{}, or from []interface will turn "" into nil values takes snake_case fields and decodes them into camelcase fields of struct used to decode values from TypeList and TypeSet of schema(`d`) directly into sdk structs

func DecodeStructToMap added in v6.4.11

func DecodeStructToMap(input interface{}) (map[string]interface{}, error)

DecodeStructToMap SDK struct to map[string]interface{}

func DiffEmptyIps added in v6.3.6

func DiffEmptyIps(_, old, new string, _ *schema.ResourceData) bool

DiffEmptyIps suppress difference when empty value for array is overwritten by API and assigned an actual IP address

func DiffSlice

func DiffSlice(slice1 []string, slice2 []string) []string

func DiffSliceOneWay

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

DiffSliceOneWay returns the elements in `a` that aren't in `b`.

func DiffToLower added in v6.3.2

func DiffToLower(_, old, new string, _ *schema.ResourceData) bool

DiffToLower terraform suppress differences between lower and upper

func DiffWithoutNewLines added in v6.3.2

func DiffWithoutNewLines(_, old, new string, _ *schema.ResourceData) bool

DiffWithoutNewLines terraform suppress differences between newlines

func GenerateEmail

func GenerateEmail() string

func GenerateImmutableError added in v6.3.6

func GenerateImmutableError(resource, field string) error

func GenerateSetError

func GenerateSetError(resource, field string, err error) error

func IsCamelCaseEqualToSnakeCase added in v6.4.11

func IsCamelCaseEqualToSnakeCase(a, b string) bool

func IsSnakeEqualToCamelCase added in v6.4.5

func IsSnakeEqualToCamelCase(a, b string) bool

func IsValidUUID added in v6.3.0

func IsValidUUID(uuid string) bool

func IsValueInSliceOfMap added in v6.4.5

func IsValueInSliceOfMap[T comparable](sliceOfMaps []interface{}, key string, value T) bool

checks if value['1'] of key[`id`] is present inside a slice of maps[string]interface{}

func MergeMaps added in v6.4.13

func MergeMaps(maps ...map[string]any) map[string]any

MergeMaps merges a slice of map[string]any entries into one map. Note: Maps should be disjoint, otherwise overlapping keys will be overwritten.

func PointerEmptyToNil added in v6.4.5

func PointerEmptyToNil() mapstructure.DecodeHookFuncType

func ReadPublicKey added in v6.4.11

func ReadPublicKey(pathOrKey string) (string, error)

ReadPublicKey Reads public key from file or directly provided and returns key string if valid

func RemoveNewLines added in v6.3.2

func RemoveNewLines(s string) string

func SetPropWithNilCheck

func SetPropWithNilCheck(m map[string]interface{}, prop string, v interface{})

func TestImageNotNull added in v6.3.0

func TestImageNotNull(resource, attribute string) resource.TestCheckFunc

func TestNotEmptySlice added in v6.3.0

func TestNotEmptySlice(resource, attribute string) resource.TestCheckFunc

func TestValueInSlice

func TestValueInSlice(resource, attribute, value string) resource.TestCheckFunc

func WaitForResourceToBeDeleted added in v6.3.4

func WaitForResourceToBeDeleted(ctx context.Context, d *schema.ResourceData, fn IsResourceDeletedFunc) error

WaitForResourceToBeDeleted - keeps retrying until resource is not found(404), or until ctx is cancelled

func WaitForResourceToBeReady added in v6.3.4

func WaitForResourceToBeReady(ctx context.Context, d *schema.ResourceData, fn ResourceReadyFunc) error

WaitForResourceToBeReady - keeps retrying until resource is ready(true is returned), or until err is thrown, or ctx is cancelled

func WriteToFile added in v6.3.3

func WriteToFile(name, value string) error

WriteToFile - creates the file and writes 'value' to it.

Types

type ApiResponseInfo added in v6.3.4

type ApiResponseInfo interface {
	HttpNotFound() bool
	LogInfo()
}

ApiResponseInfo - interface over different ApiResponse types from sdks

type IsResourceDeletedFunc added in v6.3.4

type IsResourceDeletedFunc func(ctx context.Context, d *schema.ResourceData) (bool, error)

IsResourceDeletedFunc polls api to see if resource exists based on id

type ResourceReadyFunc added in v6.3.4

type ResourceReadyFunc func(ctx context.Context, d *schema.ResourceData) (bool, error)

ResourceReadyFunc polls api to see if resource exists based on id

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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