mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-26 08:51:02 -06:00
f5da7e85c8
This will detect computed counts (which we don't currently support) and change the error to be more informative that we don't allow computed counts. Prior to this, the error would instead be something like `strconv.ParseInt: "${var.foo}" cannot be parsed as int`.
26 lines
596 B
Go
26 lines
596 B
Go
package terraform
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/hashicorp/terraform/config"
|
|
)
|
|
|
|
// EvalCountCheckComputed is an EvalNode that checks if a resource count
|
|
// is computed and errors if so. This can possibly happen across a
|
|
// module boundary and we don't yet support this.
|
|
type EvalCountCheckComputed struct {
|
|
Resource *config.Resource
|
|
}
|
|
|
|
// TODO: test
|
|
func (n *EvalCountCheckComputed) Eval(ctx EvalContext) (interface{}, error) {
|
|
if n.Resource.RawCount.Value() == unknownValue() {
|
|
return nil, fmt.Errorf(
|
|
"%s: value of 'count' cannot be computed",
|
|
n.Resource.Id())
|
|
}
|
|
|
|
return nil, nil
|
|
}
|