mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-25 01:00:16 -05:00
tofu: EvalContext expression evaluation takes context.Context (#2937)
Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
package encryption
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
@@ -39,7 +40,7 @@ type keyProviderMetadata struct {
|
||||
output keyProviderMetamap
|
||||
}
|
||||
|
||||
func newBaseEncryption(enc *encryption, target *config.TargetConfig, enforced bool, name string, staticEval *configs.StaticEvaluator) (*baseEncryption, hcl.Diagnostics) {
|
||||
func newBaseEncryption(ctx context.Context, enc *encryption, target *config.TargetConfig, enforced bool, name string, staticEval *configs.StaticEvaluator) (*baseEncryption, hcl.Diagnostics) {
|
||||
// Lookup method configs for the target, ordered by fallback precedence
|
||||
methods, diags := methodConfigsFromTarget(enc.cfg, target, name, enforced)
|
||||
if diags.HasErrors() {
|
||||
@@ -82,7 +83,7 @@ func newBaseEncryption(enc *encryption, target *config.TargetConfig, enforced bo
|
||||
|
||||
// methodConfigsFromTarget guarantees that there will be at least one encryption method. They are not optional in the common target
|
||||
// block, which is required to get to this code.
|
||||
encMethod, encDiags := setupMethod(enc.cfg, methods[0], encMeta, enc.reg, staticEval)
|
||||
encMethod, encDiags := setupMethod(ctx, enc.cfg, methods[0], encMeta, enc.reg, staticEval)
|
||||
diags = diags.Extend(encDiags)
|
||||
if diags.HasErrors() {
|
||||
return nil, diags
|
||||
@@ -152,7 +153,7 @@ const (
|
||||
)
|
||||
|
||||
// TODO Find a way to make these errors actionable / clear
|
||||
func (base *baseEncryption) decrypt(data []byte, validator func([]byte) error) ([]byte, EncryptionStatus, error) {
|
||||
func (base *baseEncryption) decrypt(ctx context.Context, data []byte, validator func([]byte) error) ([]byte, EncryptionStatus, error) {
|
||||
inputData := basedata{}
|
||||
err := json.Unmarshal(data, &inputData)
|
||||
|
||||
@@ -207,7 +208,7 @@ func (base *baseEncryption) decrypt(data []byte, validator func([]byte) error) (
|
||||
}
|
||||
|
||||
// TODO Discuss if we should potentially cache this based on a json-encoded version of inputData.Meta and reduce overhead dramatically
|
||||
decMethod, diags := setupMethod(base.enc.cfg, method, keyProviderMetadata{
|
||||
decMethod, diags := setupMethod(ctx, base.enc.cfg, method, keyProviderMetadata{
|
||||
input: inputData.Meta,
|
||||
output: outputData.Meta,
|
||||
}, base.enc.reg, base.staticEval)
|
||||
|
||||
Reference in New Issue
Block a user