func()

in internal/retry/retryable_errors.go [52:159]


func (t RetryType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
	var diags diag.Diagnostics

	attributes := in.Attributes()

	errorMessageRegexAttribute, ok := attributes["error_message_regex"]

	if !ok {
		diags.AddError(
			"Attribute Missing",
			`error_message_regex is missing from object`)

		return nil, diags
	}

	errorMessageRegexVal, ok := errorMessageRegexAttribute.(basetypes.ListValue)

	if !ok {
		diags.AddError(
			"Attribute Wrong Type",
			fmt.Sprintf(`error_message_regex expected to be basetypes.ListValue, was: %T`, errorMessageRegexAttribute))
	}

	intervalSecondsAttribute, ok := attributes["interval_seconds"]

	if !ok {
		diags.AddError(
			"Attribute Missing",
			`interval_seconds is missing from object`)

		return nil, diags
	}

	intervalSecondsVal, ok := intervalSecondsAttribute.(basetypes.Int64Value)

	if !ok {
		diags.AddError(
			"Attribute Wrong Type",
			fmt.Sprintf(`interval_seconds expected to be basetypes.Int64Value, was: %T`, intervalSecondsAttribute))
	}

	maxIntervalSecondsAttribute, ok := attributes["max_interval_seconds"]

	if !ok {
		diags.AddError(
			"Attribute Missing",
			`max_interval_seconds is missing from object`)

		return nil, diags
	}

	maxIntervalSecondsVal, ok := maxIntervalSecondsAttribute.(basetypes.Int64Value)

	if !ok {
		diags.AddError(
			"Attribute Wrong Type",
			fmt.Sprintf(`max_interval_seconds expected to be basetypes.Int64Value, was: %T`, maxIntervalSecondsAttribute))
	}

	multiplierAttribute, ok := attributes["multiplier"]

	if !ok {
		diags.AddError(
			"Attribute Missing",
			`multiplier is missing from object`)

		return nil, diags
	}

	multiplierVal, ok := multiplierAttribute.(basetypes.Float64Value)

	if !ok {
		diags.AddError(
			"Attribute Wrong Type",
			fmt.Sprintf(`multiplier expected to be basetypes.Float64Value, was: %T`, multiplierAttribute))
	}

	randomizationFactorAttribute, ok := attributes["randomization_factor"]

	if !ok {
		diags.AddError(
			"Attribute Missing",
			`randomization_factor is missing from object`)

		return nil, diags
	}

	randomizationFactorVal, ok := randomizationFactorAttribute.(basetypes.Float64Value)

	if !ok {
		diags.AddError(
			"Attribute Wrong Type",
			fmt.Sprintf(`randomization_factor expected to be basetypes.Float64Value, was: %T`, randomizationFactorAttribute))
	}

	if diags.HasError() {
		return nil, diags
	}

	return RetryValue{
		ErrorMessageRegex:   errorMessageRegexVal,
		IntervalSeconds:     intervalSecondsVal,
		MaxIntervalSeconds:  maxIntervalSecondsVal,
		Multiplier:          multiplierVal,
		RandomizationFactor: randomizationFactorVal,
		state:               attr.ValueStateKnown,
	}, diags
}