getproviders: context.Context for source constructor functions

This completes some of the missing connections for contexts in the provider
source codepaths by introducing context.Context parameters and wiring them
through so we can eliminate a few more context.TODO() placeholders.

For consistency's sake this adds context.Context to all four of the
getproviders.Source implementations that directly interact with stuff
outside of OpenTofu (network services or filesystem), even though not
all of them currently make use of it, just because interactions with
outside stuff tends to encourage cross-cutting concerns like logging and
tracing and so this ensures we have contexts propagated in there for such
future uses.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
This commit is contained in:
Martin Atkins
2025-06-12 11:15:03 -07:00
parent 324ef91c4e
commit 00dc728aea
14 changed files with 39 additions and 36 deletions

View File

@@ -7,6 +7,7 @@ package command
import (
"bytes"
"context"
"errors"
"fmt"
"log"
@@ -93,11 +94,11 @@ func (m *Meta) providerInstallerCustomSource(source getproviders.Source) *provid
//
// If the given list of directories is empty then the resulting source will
// have no providers available for installation at all.
func (m *Meta) providerCustomLocalDirectorySource(dirs []string) getproviders.Source {
func (m *Meta) providerCustomLocalDirectorySource(ctx context.Context, dirs []string) getproviders.Source {
var ret getproviders.MultiSource
for _, dir := range dirs {
ret = append(ret, getproviders.MultiSourceSelector{
Source: getproviders.NewFilesystemMirrorSource(dir),
Source: getproviders.NewFilesystemMirrorSource(ctx, dir),
})
}
return ret