mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-19 17:59:05 -05:00
It seems that a small number of providers are now able to return a special signal when they find that they are unable to perform an operation due to unknown values in the provider or resource configuration. This is a uses that new signal to recommend a workaround in that situation, giving a more actionable error message than would've been returned by the provider otherwise. We've not yet decided how OpenTofu might make use of these new signals in the long term, and so this is intentionally implemented in a way where most of the logic is centralized in the provider-related packages rather than sprawled all over "package tofu". It's likely that a future incarnation of this will plumb this idea in more deeply, but this is just a temporary stop-gap to give slightly better error messages in the meantime and so it's better to keep it relatively contained for now until we have a longer-term plan for what OpenTofu Core might do with this information. Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
25 lines
742 B
Go
25 lines
742 B
Go
// Copyright (c) The OpenTofu Authors
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
// Copyright (c) 2023 HashiCorp, Inc.
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
package convert
|
|
|
|
import (
|
|
"github.com/opentofu/opentofu/internal/providers"
|
|
"github.com/opentofu/opentofu/internal/tfplugin5"
|
|
)
|
|
|
|
func DeferralReasonFromProto(reason tfplugin5.Deferred_Reason) providers.DeferralReason {
|
|
switch reason {
|
|
case tfplugin5.Deferred_RESOURCE_CONFIG_UNKNOWN:
|
|
return providers.DeferredBecauseResourceConfigUnknown
|
|
case tfplugin5.Deferred_PROVIDER_CONFIG_UNKNOWN:
|
|
return providers.DeferredBecauseProviderConfigUnknown
|
|
case tfplugin5.Deferred_ABSENT_PREREQ:
|
|
return providers.DeferredBecausePrereqAbsent
|
|
default:
|
|
return providers.DeferredReasonUnknown
|
|
}
|
|
}
|