Files
opentf/internal/plugin6/convert/deferral.go
Martin Atkins e389ae3974 providers: Recommend -exclude when provider can't plan
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>
2025-06-13 09:17:36 -07:00

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/tfplugin6"
)
func DeferralReasonFromProto(reason tfplugin6.Deferred_Reason) providers.DeferralReason {
switch reason {
case tfplugin6.Deferred_RESOURCE_CONFIG_UNKNOWN:
return providers.DeferredBecauseResourceConfigUnknown
case tfplugin6.Deferred_PROVIDER_CONFIG_UNKNOWN:
return providers.DeferredBecauseProviderConfigUnknown
case tfplugin6.Deferred_ABSENT_PREREQ:
return providers.DeferredBecausePrereqAbsent
default:
return providers.DeferredReasonUnknown
}
}