Files
opentf/internal/lang/eval/provider_instance.go
Martin Atkins af3bd79a03 lang/eval: Work-in-progress changes to modeling of module tree
Exposing only "ResourceInstancesDeep" on CompiledModuleInstance seemed
attractive at first when it was only partially implemented anyway, but
trying to finish implementing it revealed that the current design couldn't
actually support that API because we don't currently keep the
CompiledModuleInstance object for a child module instance after we've used
it to evaluate the child module instance's output values.

This commit doesn't actually solve that problem, but it does rework the
CompiledModuleInstance API so that the problem of finding and enumerating
child module instances is separated from the problem of finding resource
instances in just the current module instance, and then I'll try to find
a good way to satisfy this new, slightly-generalized API in future commits.

(The ultimate goal here is to be able to enumerate all of the resource
instances throughout the configuration for dependency-tracking purposes,
and to be able to find a specific ProviderInstance object given its
absolute address so that the plan or apply engine can request the
configuration value to configure the provider with.)

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-10-27 10:15:41 -07:00

33 lines
1.1 KiB
Go

// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package eval
import (
"github.com/zclconf/go-cty/cty"
"github.com/opentofu/opentofu/internal/addrs"
)
// ProviderInstanceConfig provides the information needed to either instantiate
// and configure a provider instance for the first time or to find a
// previously-configured object for the same provider instance.
type ProviderInstanceConfig struct {
// Addr is the address for the provider instance, unique across the whole
// configuration.
//
// This is a good key to use for a table of previously-configured provider
// objects.
Addr addrs.AbsProviderInstanceCorrect
// ConfigVal is the configuration value to send to the provider when
// configuring it. The relationship between Addr and ConfigVal is
// guaranteed to be consistent for all ProviderInstanceConfig objects
// produced through a particular [ConfigInstance], and so it's safe
// to reuse a previously-configured provider (and thus ignore ConfigVal)
// when the address matches.
ConfigVal cty.Value
}