utils

package
v3.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2021 License: MPL-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DatadogProvider *schema.Provider

DatadogProvider holds a reference to the provider

Functions

func AccountAndLambdaArnFromID

func AccountAndLambdaArnFromID(id string) (string, string, error)

AccountAndLambdaArnFromID returns account and Lambda ARN from an ID

func AccountAndNamespaceFromID

func AccountAndNamespaceFromID(id string) (string, string, error)

AccountAndNamespaceFromID returns account and namespace from an ID

func AccountAndRoleFromID

func AccountAndRoleFromID(id string) (string, string, error)

AccountAndRoleFromID returns account and role from an ID

func AccountNameAndChannelNameFromID

func AccountNameAndChannelNameFromID(id string) (string, string, error)

AccountNameAndChannelNameFromID returns slack account and channel from an ID

func CheckForUnparsed

func CheckForUnparsed(resp interface{}) error

CheckForUnparsed takes in a API response object and returns an error if it contains an unparsed element

func ConvertResponseByteToMap

func ConvertResponseByteToMap(b []byte) (map[string]interface{}, error)

ConvertResponseByteToMap converts JSON []byte to map[string]interface{}

func ConvertToSha256

func ConvertToSha256(content string) string

ConvertToSha256 builds a SHA256 hash of the passed string

func DeleteKeyInMap

func DeleteKeyInMap(mapObject map[string]interface{}, keyList []string)

DeleteKeyInMap deletes key (in dot notation) in map

func GetMetadataFromJSON

func GetMetadataFromJSON(jsonBytes []byte, unmarshalled interface{}) error

GetMetadataFromJSON decodes passed JSON data

func GetUserAgent

func GetUserAgent(clientUserAgent string) string

GetUserAgent augments the default user agent with provider details

func Retry

func Retry(interval time.Duration, count int, call func() error) error

Retry calls the call function for count times every interval while it returns a RetryableError Call function should return either: nil, RetryableError, or FatalError nil indicates a success condition was met RetryableError means we'll retry up to the count FatalError indicates we shouldn't try the request again

func SendRequest

func SendRequest(ctx context.Context, client *datadogV1.APIClient, method, path string, body interface{}) ([]byte, *http.Response, error)

SendRequest send custom request

func TenantAndClientFromID

func TenantAndClientFromID(id string) (string, string, error)

TenantAndClientFromID returns azure account and client from an ID

func TranslateClientError

func TranslateClientError(err error, httpresp *http.Response, msg string) error

TranslateClientError turns an error into a message

func TranslateClientErrorDiag

func TranslateClientErrorDiag(err error, httpresp *http.Response, msg string) diag.Diagnostics

TranslateClientErrorDiag returns client error as type diag.Diagnostics

Types

type CustomRequestAPIError

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

CustomRequestAPIError Provides access to the body, and error on returned errors.

func (CustomRequestAPIError) Body

func (e CustomRequestAPIError) Body() []byte

Body returns the raw bytes of the response

func (CustomRequestAPIError) Error

func (e CustomRequestAPIError) Error() string

Error returns non-empty string if there was an error.

type FatalError

type FatalError struct {
	Prob string
}

FatalError should be considered final and not trigger any retries

func (*FatalError) Error

func (e *FatalError) Error() string

type ResourceDataKey

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

ResourceDataKey structure holds Terraform's *schema.ResourceData structure and a slice of strings that hold a "key" to somewhere in the stored data. For example, []string{"foo", "0", "bar"} would point to "foo.0.bar". This allows for easy extraction of the data while adding/removing parts of the "key".

func NewResourceDataKey

func NewResourceDataKey(d *schema.ResourceData, initial string) *ResourceDataKey

NewResourceDataKey creates a new ResourceDataKey with given initial key (can be given with dotted notation, e.g. "foo.0.bar").

func (*ResourceDataKey) Add

func (k *ResourceDataKey) Add(newParts interface{}) *ResourceDataKey

Add adds new parts to the stored key. The argument can either be a string using dotted notation (e.g. "foo.0.bar") or an int (assumed to be a list index and converted to string).

func (*ResourceDataKey) Get

func (k *ResourceDataKey) Get() interface{}

Get calls the "Get" method on the stored ResourceData structure with the current key (obtained by S).

func (*ResourceDataKey) GetOk

func (k *ResourceDataKey) GetOk() (interface{}, bool)

GetOk calls the "GetOk" method on the stored ResourceData structure with the current key (obtained by S).

func (*ResourceDataKey) GetOkWith

func (k *ResourceDataKey) GetOkWith(parts interface{}) (interface{}, bool)

GetOkWith calls the "GetOk" method on the stored ResourceData structure with the current key plus given parts (obtained by With, meaning that the parts are not added permanently).

func (*ResourceDataKey) GetWith

func (k *ResourceDataKey) GetWith(parts interface{}) interface{}

GetWith calls the "Get" method on the stored ResourceData structure with the current key plus given parts (obtained by With, meaning that the parts are not added permanently).

func (*ResourceDataKey) Pop

func (k *ResourceDataKey) Pop(removeCount int) *ResourceDataKey

Pop will remove given count of key parts from the end of the key. Panics if given count is bigger than number of key parts.

func (*ResourceDataKey) Remove

func (k *ResourceDataKey) Remove(parts interface{}) *ResourceDataKey

Remove like Add, but removes given key parts from the end of the key. Panics if the key doesn't end with given parts.

func (*ResourceDataKey) S

func (k *ResourceDataKey) S() string

S returns string representation of the key, e.g. "foo.0.bar".

func (*ResourceDataKey) With

func (k *ResourceDataKey) With(parts interface{}) string

With returns string representation of the key (much like S) with given parts added, but doesn't add the parts permanently.

type RetryableError

type RetryableError struct {
	Prob string
}

RetryableError represents a transient error and means its safe to try the request again

func (*RetryableError) Error

func (e *RetryableError) Error() string

Jump to

Keyboard shortcuts

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