Wire pool resource targets through runner and repair quarantined-member handoff
This commit is contained in:
@@ -5,8 +5,34 @@ package stage
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"git.a-wan.net/alan/pipelines/internal/protocol"
|
||||
)
|
||||
|
||||
type resourceTargetContextKey struct{}
|
||||
|
||||
// WithResourceTarget attaches the server-granted concrete target to a stage's
|
||||
// runtime context. It is deliberately separate from model input and contains
|
||||
// no capability or credential material.
|
||||
func WithResourceTarget(ctx context.Context, target *protocol.ResourceTarget) context.Context {
|
||||
if target == nil {
|
||||
return ctx
|
||||
}
|
||||
copy := &protocol.ResourceTarget{Member: target.Member}
|
||||
if target.Metadata != nil {
|
||||
copy.Metadata = map[string]string{}
|
||||
for key, value := range target.Metadata {
|
||||
copy.Metadata[key] = value
|
||||
}
|
||||
}
|
||||
return context.WithValue(ctx, resourceTargetContextKey{}, copy)
|
||||
}
|
||||
|
||||
func ResourceTarget(ctx context.Context) (*protocol.ResourceTarget, bool) {
|
||||
target, ok := ctx.Value(resourceTargetContextKey{}).(*protocol.ResourceTarget)
|
||||
return target, ok
|
||||
}
|
||||
|
||||
// Values are runtime data, not the prose output contract in a definition.
|
||||
type Values map[string]any
|
||||
|
||||
|
||||
Reference in New Issue
Block a user