backend: Backend.StateMgr takes context.Context

This adds a new context.Context argument to the Backend.StateMgr method,
updates all of the implementations to match, and then updates all of the
callers to pass in a context.

A small number of callers don't yet have context plumbed to them so those
use context.TODO() as a placeholder for now, so we can more easily find
and fix them in later commits once we have contexts more thoroughly
plumbed.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
This commit is contained in:
Martin Atkins
2025-05-06 13:50:41 -07:00
parent b9573139ab
commit 601e84ee71
72 changed files with 246 additions and 246 deletions

View File

@@ -79,7 +79,7 @@ func (b *Backend) DeleteWorkspace(name string, _ bool) error {
}
// StateMgr manage the state, if the named state not exists, a new file will created
func (b *Backend) StateMgr(name string) (statemgr.Full, error) {
func (b *Backend) StateMgr(ctx context.Context, name string) (statemgr.Full, error) {
log.Printf("[DEBUG] state manager, current workspace: %v", name)
c, err := b.client(name)
@@ -88,7 +88,7 @@ func (b *Backend) StateMgr(name string) (statemgr.Full, error) {
}
stateMgr := remote.NewState(c, b.encryption)
ws, err := b.Workspaces(context.TODO())
ws, err := b.Workspaces(ctx)
if err != nil {
return nil, err
}