utils

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2024 License: MPL-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CustomHttpRequestRetry

func CustomHttpRequestRetry[T any](ctx context.Context, maxRetries int, initialRetryDelay time.Duration, apiCall func() (T, *http.Response, error)) (T, *http.Response, error)

CustomHttpRequestRetry Helper function for retrying API calls. This is to recover from backend congestion errors which manifest as 4XX response codes

func CustomHttpRequestRetryStronglyTyped

func CustomHttpRequestRetryStronglyTyped[T any](ctx context.Context, maxRetries int, retryDelay time.Duration, apiCall func() (T, *http.Response, error, diag.Diagnostics)) (T, *http.Response, error, diag.Diagnostics)

CustomHttpRequestRetryStronglyTyped is a generic function that leverages CustomHttpRequestRetry

func Decrypt

func Decrypt(key, cryptoText string) (string, error)

Decrypt decrypts the given ciphertext with the provided key.

func Encrypt

func Encrypt(key, text string) (string, error)

Encrypt encrypts the given plaintext with the provided key.

func ExtractBoolAttr

func ExtractBoolAttr(hashMap map[string]interface{}, key string) (types.Bool, diag.Diagnostics)

ExtractBoolAttr Extracts a bool attribute from a hashmap

func ExtractFloat32Attr

func ExtractFloat32Attr(hashMap map[string]interface{}, key string) (types.Float64, diag.Diagnostics)

ExtractFloat32Attr Extracts a float attribute from a hashmap

func ExtractFloat64Attr

func ExtractFloat64Attr(hashMap map[string]interface{}, key string) (types.Float64, diag.Diagnostics)

ExtractFloat64Attr Extracts a float attribute from a hashmap

func ExtractInt32Attr

func ExtractInt32Attr(hashMap map[string]interface{}, key string) (types.Int64, diag.Diagnostics)

ExtractInt32Attr Extracts an int64 attribute from a hashmap

func ExtractInt64Attr

func ExtractInt64Attr(hashMap map[string]interface{}, key string) (types.Int64, diag.Diagnostics)

ExtractInt64Attr Extracts an int64 attribute from a hashmap

func ExtractInt64FromFloat added in v0.12.0

func ExtractInt64FromFloat(hashMap map[string]interface{}, key string) (types.Int64, diag.Diagnostics)

func ExtractListAttr

func ExtractListAttr(hashMap map[string]interface{}, key string, elemType attr.Type) (types.List, diag.Diagnostics)

ExtractListAttr extracts a list attribute from a hashmap

func ExtractListStringAttr

func ExtractListStringAttr(hashMap map[string]interface{}, key string) (types.List, diag.Diagnostics)

ExtractListStringAttr extracts a slice of string attributes from a hashmap

func ExtractObjectAttr

func ExtractObjectAttr(hashMap map[string]interface{}, key string, attrTypes map[string]attr.Type) (types.Object, diag.Diagnostics)

ExtractObjectAttr extracts an object attribute from a hashmap

func ExtractResponseToMap

func ExtractResponseToMap(resp *http.Response) (map[string]interface{}, error)

ExtractResponseToMap reads an HTTP response body and unmarshals the JSON content into a map[string]interface{}. It returns the map along with any error that occurs during the read or unmarshal process.

func ExtractStringAttr

func ExtractStringAttr(hashMap map[string]interface{}, key string) (types.String, diag.Diagnostics)

ExtractStringAttr Extracts a string attribute from a hashmap

func ExtractStringsFromList

func ExtractStringsFromList(array types.List) ([]string, diag.Diagnostics)

func Float32Pointer

func Float32Pointer(input float64) (*float32, diag.Diagnostics)

Float32Pointer Convert float64 to *float32 with error handling

func Float64Pointer

func Float64Pointer(input float32) (*float64, diag.Diagnostics)

Float64Pointer Convert float32 to *float64 with error handling

func HttpDiagnostics

func HttpDiagnostics(httpResp *http.Response) string

HttpDiagnostics - responsible for gathering and logging HTTP driven events

func Int32Pointer

func Int32Pointer(input int64) (*int32, diag.Diagnostics)

Int32Pointer Convert int64 to *int32 with error handling

func ListInt64TypeToInt32Array

func ListInt64TypeToInt32Array(data types.List) ([]int32, diag.Diagnostics)

func LogCurrentState

func LogCurrentState(t *testing.T) resource.TestCheckFunc

LogCurrentState LogCurrentStat Custom test check function to log the current state

func NewBoolDefault

func NewBoolDefault(defaultValue bool) defaults.Bool

NewBoolDefault returns a struct that implements the defaults.Bool interface for a resource Schema

func NewFloat64Default

func NewFloat64Default(defaultValue float64) defaults.Float64

NewFloat64Default returns a struct that implements the defaults.Float64 interface for a resource Schema

func NewHttpDiagnostics

func NewHttpDiagnostics(httpResp *http.Response, bodyContent string) string

NewHttpDiagnostics - responsible for gathering and logging HTTP driven events

func NewInt64Default

func NewInt64Default(defaultValue int64) defaults.Int64

NewInt64Default returns a struct that implements the defaults.Int64 interface for a resource Schema

func NewSensitivePlanModifier

func NewSensitivePlanModifier(encryptionKey string) planmodifier.String

func NewStringDefault

func NewStringDefault(defaultValue string) defaults.String

NewStringDefault returns a struct that implements the defaults.String interface for a resource Schema

func ReadAndCloseBody

func ReadAndCloseBody(httpResp *http.Response) (string, error)

ReadAndCloseBody Define a helper function to read and close the HTTP response body

Types

type RequiresReplaceIfSensitive

type RequiresReplaceIfSensitive struct{}

RequiresReplaceIfSensitive Custom plan modifier to require replacement if the sensitive attribute changes

func (RequiresReplaceIfSensitive) Description

func (RequiresReplaceIfSensitive) MarkdownDescription

func (r RequiresReplaceIfSensitive) MarkdownDescription(context.Context) string

func (RequiresReplaceIfSensitive) PlanModifyString

type SensitivePlanModifier

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

func (SensitivePlanModifier) Description

func (m SensitivePlanModifier) Description(ctx context.Context) string

func (SensitivePlanModifier) MarkdownDescription

func (m SensitivePlanModifier) MarkdownDescription(ctx context.Context) string

func (SensitivePlanModifier) PlanModifyString

Jump to

Keyboard shortcuts

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