utilities

package
v1.0.16 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrWrongHumanReadableFormat  = errors.New("wrong format, expected human-readable time period (e.g. 2d, 3w5h, 1Y32D)")
	ErrWrongISO8601MinutesFormat = errors.New("wrong format, expected ISO8601 minutes (e.g. PT10M)")
)
View Source
var ErrImmutableFieldChanged error = errors.New("attempt to update an immutable field")

Functions

func AllValid added in v1.0.12

func AllowedDataUnitSuffix added in v1.0.12

func AllowedDataUnitSuffix(suffixes ...byte) schema.SchemaValidateDiagFunc

func CheckBoolAttribute added in v1.0.12

func CheckBoolAttribute(t *testing.T, attributeName string, found bool, stored string) bool

func CheckImmutableFields added in v1.0.16

func CheckImmutableFields(ctx context.Context, d *schema.ResourceData, fieldNames ...string) error

func CheckImmutableFieldsExcept added in v1.0.12

func CheckImmutableFieldsExcept(ctx context.Context, d *schema.ResourceData, fieldNames ...string) error

func CheckStrAttribute added in v1.0.12

func CheckStrAttribute(t *testing.T, attributeName, found, stored string) bool

func CheckTestSkip added in v1.0.16

func CheckTestSkip(t *testing.T)

func ConvertDataUnitsToInt64 added in v1.0.12

func ConvertDataUnitsToInt64(number string, factor int) (int64, error)

func DataUnitsBeetween added in v1.0.12

func DataUnitsBeetween(min, max int64, factor int) schema.SchemaValidateDiagFunc

func GetDiffSuppressForDataUnits added in v1.0.12

func GetDiffSuppressForDataUnits(factor int) schema.SchemaDiffSuppressFunc

func GetIdForDataSource added in v1.0.12

func GetIdForDataSource() string

func IsAddressInPrefix added in v1.0.12

func IsAddressInPrefix(addr, prefix string) bool

func IsValidAddress added in v1.0.12

func IsValidAddress(addr string) bool

func IsValidCidr added in v1.0.16

func IsValidCidr(prefix string) bool

func MinutesToStringISO8601 added in v1.0.12

func MinutesToStringISO8601(minutes int) string

func ParseHumanReadableTimePeriodIntoMinutes added in v1.0.12

func ParseHumanReadableTimePeriodIntoMinutes(s string) (int, error)
func ParseSelfLink(selfLink string, orderedRequiredGroupNamesInPath []string) (map[string]string, error)

Generic function for parsing self links. We assume that this helper function is called with ordered list of resource group names

func ProcessClientError added in v1.0.1

func ProcessClientError(ctx context.Context, op string, err error) diag.Diagnostics

func Retry

func Retry(ctx context.Context, retryTime time.Duration, backoffFactor float32, attemptLimit int, retryContext string, f func() (stop bool, err error)) error

Runs f in a loop if it has failed, until attempts reaches attemptLimit retryTime is a duration to cooldown between attempts retryContext is a string that is included in log output backoffFactor is a float that determines how much to increase retryTime if backoffFactor is 0.0, then there is no backoff increase if backoffFactor is 1.0, then there is a 100% increase, so it doubles each time if backoffFactor is 0.5, then there is a 50% increase, ie maybe 100, then 150, then 225... f returns a bool (stop) if that is true, we won't retry anymore

func StringISO8601MinutesToInt added in v1.0.12

func StringISO8601MinutesToInt(s string) (int, error)

func StringIsInt64 added in v1.0.16

func StringIsInt64(value any, p cty.Path) diag.Diagnostics

func TestCheckDataSource added in v1.0.12

func TestCheckDataSource(
	dataSourceType, dataSourceName, listFieldName string, items []map[string]interface{},
) resource.TestCheckFunc

func TestCheckDataSourceExact added in v1.0.12

func TestCheckDataSourceExact(
	dataSourceType, dataSourceName, listFieldName string, items []map[string]interface{},
) resource.TestCheckFunc

func TestCheckDataSourceNotHave added in v1.0.16

func TestCheckDataSourceNotHave(
	dataSourceType, dataSourceName, listFieldName string, items []map[string]interface{},
) resource.TestCheckFunc

func TraceError

func TraceError(ctx context.Context, err error)

Recursively print error details

func TraceOperation added in v1.0.1

func TraceOperation(ctx context.Context, op *hmrest.Operation, userMessage string)

func TracePatch added in v1.0.12

func TracePatch(ctx context.Context, resourceType string, resourceName string, parameterName string, value interface{}, patchIdx int)

func WaitOnOperation added in v1.0.1

func WaitOnOperation(ctx context.Context, op *hmrest.Operation, client *hmrest.APIClient) (succeeded bool, err error)

Wait on an operation until its status reaches Succeeded (or Completed) or Failed. Return succeeded = true if status reaches Succeeded (or Completed), Failed if status reached Failed, and err otherwise. On return,

 op will be up to date with the most recent GET of the operation, EVEN when we're returning an error.
	if err != nil, then we have an error. Ignore succeeded (it will be false, but it doesn't mean the operation failed.)
 If err == nil, then check succeeded. It is true iff (op.Status == "Succeeded" || op.Status == "Completed") && op.Status != "Failed"

Types

type RestError added in v1.0.12

type RestError struct {
	OperationType string
	PureCode      string
	HttpCode      string
	Message       string
}

func NewRestErrorFromOperation added in v1.0.12

func NewRestErrorFromOperation(operation *hmrest.Operation) *RestError

func (*RestError) Error added in v1.0.12

func (e *RestError) Error() string

Jump to

Keyboard shortcuts

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