2024-02-08 03:48:59 -06:00
|
|
|
// Copyright (c) The OpenTofu Authors
|
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
// Copyright (c) 2023 HashiCorp, Inc.
|
2023-05-02 10:33:06 -05:00
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
2018-04-03 20:11:28 -05:00
|
|
|
package lang
|
|
|
|
|
|
|
|
import (
|
2023-06-28 02:47:24 -05:00
|
|
|
"github.com/zclconf/go-cty/cty"
|
|
|
|
|
2023-09-20 06:35:35 -05:00
|
|
|
"github.com/opentofu/opentofu/internal/addrs"
|
|
|
|
"github.com/opentofu/opentofu/internal/tfdiags"
|
2018-04-03 20:11:28 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
// Data is an interface whose implementations can provide cty.Value
|
|
|
|
// representations of objects identified by referenceable addresses from
|
|
|
|
// the addrs package.
|
|
|
|
//
|
|
|
|
// This interface will grow each time a new type of reference is added, and so
|
2023-09-20 07:59:27 -05:00
|
|
|
// implementations outside of the OpenTofu codebases are not advised.
|
2018-04-03 20:11:28 -05:00
|
|
|
//
|
|
|
|
// Each method returns a suitable value and optionally some diagnostics. If the
|
|
|
|
// returned diagnostics contains errors then the type of the returned value is
|
|
|
|
// used to construct an unknown value of the same type which is then used in
|
|
|
|
// place of the requested object so that type checking can still proceed. In
|
|
|
|
// cases where it's not possible to even determine a suitable result type,
|
|
|
|
// cty.DynamicVal is returned along with errors describing the problem.
|
|
|
|
type Data interface {
|
2023-03-10 04:11:10 -06:00
|
|
|
StaticValidateReferences(refs []*addrs.Reference, self addrs.Referenceable, source addrs.Referenceable) tfdiags.Diagnostics
|
2018-11-20 19:25:05 -06:00
|
|
|
|
2018-04-03 20:11:28 -05:00
|
|
|
GetCountAttr(addrs.CountAttr, tfdiags.SourceRange) (cty.Value, tfdiags.Diagnostics)
|
2019-06-12 10:07:32 -05:00
|
|
|
GetForEachAttr(addrs.ForEachAttr, tfdiags.SourceRange) (cty.Value, tfdiags.Diagnostics)
|
2019-08-23 18:20:47 -05:00
|
|
|
GetResource(addrs.Resource, tfdiags.SourceRange) (cty.Value, tfdiags.Diagnostics)
|
2018-04-03 20:11:28 -05:00
|
|
|
GetLocalValue(addrs.LocalValue, tfdiags.SourceRange) (cty.Value, tfdiags.Diagnostics)
|
2020-04-12 09:43:41 -05:00
|
|
|
GetModule(addrs.ModuleCall, tfdiags.SourceRange) (cty.Value, tfdiags.Diagnostics)
|
2018-04-03 20:11:28 -05:00
|
|
|
GetPathAttr(addrs.PathAttr, tfdiags.SourceRange) (cty.Value, tfdiags.Diagnostics)
|
|
|
|
GetTerraformAttr(addrs.TerraformAttr, tfdiags.SourceRange) (cty.Value, tfdiags.Diagnostics)
|
|
|
|
GetInputVariable(addrs.InputVariable, tfdiags.SourceRange) (cty.Value, tfdiags.Diagnostics)
|
2023-06-28 02:47:24 -05:00
|
|
|
GetOutput(addrs.OutputValue, tfdiags.SourceRange) (cty.Value, tfdiags.Diagnostics)
|
|
|
|
GetCheckBlock(addrs.Check, tfdiags.SourceRange) (cty.Value, tfdiags.Diagnostics)
|
2018-04-03 20:11:28 -05:00
|
|
|
}
|