mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-25 01:00:16 -05:00
builtin/providers/tf: pass real context.Context to backend methods (#2938)
Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
This commit is contained in:
@@ -106,7 +106,7 @@ func dataSourceRemoteStateValidate(cfg cty.Value) tfdiags.Diagnostics {
|
||||
return diags
|
||||
}
|
||||
|
||||
func dataSourceRemoteStateRead(d cty.Value, enc encryption.StateEncryption, path addrs.AbsResourceInstance) (cty.Value, tfdiags.Diagnostics) {
|
||||
func dataSourceRemoteStateRead(ctx context.Context, d cty.Value, enc encryption.StateEncryption, path addrs.AbsResourceInstance) (cty.Value, tfdiags.Diagnostics) {
|
||||
var diags tfdiags.Diagnostics
|
||||
|
||||
b, cfg, moreDiags := getBackend(d, enc)
|
||||
@@ -115,9 +115,7 @@ func dataSourceRemoteStateRead(d cty.Value, enc encryption.StateEncryption, path
|
||||
return cty.NilVal, diags
|
||||
}
|
||||
|
||||
// TODO: Plumb a real context in here, once [providers.Interface] has
|
||||
// been updated to allow one to pass through its API.
|
||||
configureDiags := b.Configure(context.TODO(), cfg)
|
||||
configureDiags := b.Configure(ctx, cfg)
|
||||
if configureDiags.HasErrors() {
|
||||
diags = diags.Append(configureDiags.Err())
|
||||
return cty.NilVal, diags
|
||||
@@ -137,7 +135,7 @@ func dataSourceRemoteStateRead(d cty.Value, enc encryption.StateEncryption, path
|
||||
workspaceName = workspaceVal.AsString()
|
||||
}
|
||||
|
||||
state, err := b.StateMgr(context.TODO(), workspaceName)
|
||||
state, err := b.StateMgr(ctx, workspaceName)
|
||||
if err != nil {
|
||||
diags = diags.Append(tfdiags.AttributeValue(
|
||||
tfdiags.Error,
|
||||
|
||||
@@ -328,7 +328,7 @@ func TestState_basic(t *testing.T) {
|
||||
var got cty.Value
|
||||
if !diags.HasErrors() && config.IsWhollyKnown() {
|
||||
var moreDiags tfdiags.Diagnostics
|
||||
got, moreDiags = dataSourceRemoteStateRead(config, encryption.StateEncryptionDisabled(), addrs.AbsResourceInstance{
|
||||
got, moreDiags = dataSourceRemoteStateRead(t.Context(), config, encryption.StateEncryptionDisabled(), addrs.AbsResourceInstance{
|
||||
Resource: addrs.ResourceInstance{
|
||||
Resource: addrs.Resource{
|
||||
Mode: addrs.DataResourceMode,
|
||||
|
||||
@@ -91,7 +91,7 @@ func (p *Provider) ReadDataSource(_ context.Context, req providers.ReadDataSourc
|
||||
panic("Should not be called directly, special case for terraform_remote_state")
|
||||
}
|
||||
|
||||
func (p *Provider) ReadDataSourceEncrypted(_ context.Context, req providers.ReadDataSourceRequest, path addrs.AbsResourceInstance, enc encryption.Encryption) providers.ReadDataSourceResponse {
|
||||
func (p *Provider) ReadDataSourceEncrypted(ctx context.Context, req providers.ReadDataSourceRequest, path addrs.AbsResourceInstance, enc encryption.Encryption) providers.ReadDataSourceResponse {
|
||||
// call function
|
||||
var res providers.ReadDataSourceResponse
|
||||
|
||||
@@ -113,7 +113,7 @@ func (p *Provider) ReadDataSourceEncrypted(_ context.Context, req providers.Read
|
||||
|
||||
log.Printf("[DEBUG] accessing remote state at %s", key)
|
||||
|
||||
newState, diags := dataSourceRemoteStateRead(req.Config, enc.RemoteState(key), path)
|
||||
newState, diags := dataSourceRemoteStateRead(ctx, req.Config, enc.RemoteState(key), path)
|
||||
|
||||
if diags.HasErrors() {
|
||||
diags = diags.Append(fmt.Errorf("%s: Unable to read remote state", path.String()))
|
||||
|
||||
Reference in New Issue
Block a user