| 127 | } |
| 128 | |
| 129 | func (s staticScopeData) GetLocalValue(ctx context.Context, ident addrs.LocalValue, rng tfdiags.SourceRange) (cty.Value, tfdiags.Diagnostics) { |
| 130 | var diags tfdiags.Diagnostics |
| 131 | |
| 132 | local, ok := s.eval.cfg.Locals[ident.Name] |
| 133 | if !ok { |
| 134 | return cty.DynamicVal, diags.Append(&hcl.Diagnostic{ |
| 135 | Severity: hcl.DiagError, |
| 136 | Summary: "Undefined local", |
| 137 | Detail: fmt.Sprintf("Undefined local %s", ident.String()), |
| 138 | Subject: rng.ToHCL().Ptr(), |
| 139 | }) |
| 140 | } |
| 141 | |
| 142 | id := StaticIdentifier{ |
| 143 | Module: s.eval.call.addr, |
| 144 | Subject: fmt.Sprintf("local.%s", local.Name), |
| 145 | DeclRange: local.DeclRange, |
| 146 | } |
| 147 | |
| 148 | scope, scopeDiags := s.scope(id) |
| 149 | diags = diags.Append(scopeDiags) |
| 150 | if diags.HasErrors() { |
| 151 | return cty.DynamicVal, diags |
| 152 | } |
| 153 | |
| 154 | val, valDiags := scope.EvalExpr(ctx, local.Expr, cty.DynamicPseudoType) |
| 155 | return val, s.enhanceDiagnostics(id, diags.Append(valDiags)) |
| 156 | } |
| 157 | |
| 158 | func (s staticScopeData) GetModule(context.Context, addrs.ModuleCall, tfdiags.SourceRange) (cty.Value, tfdiags.Diagnostics) { |
| 159 | panic("Not Available in Static Context") |