From 89dd3870b32d9659e229da9867ce58e2f5fa998f Mon Sep 17 00:00:00 2001 From: Ryan McKinley Date: Mon, 12 Jan 2026 10:47:05 +0300 Subject: [PATCH] with context --- pkg/storage/legacysql/dualwrite/context.go | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 pkg/storage/legacysql/dualwrite/context.go diff --git a/pkg/storage/legacysql/dualwrite/context.go b/pkg/storage/legacysql/dualwrite/context.go new file mode 100644 index 00000000000..9d9961baa82 --- /dev/null +++ b/pkg/storage/legacysql/dualwrite/context.go @@ -0,0 +1,35 @@ +package dualwrite + +import ( + "context" + + common "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1" +) + +type ctxKey struct{} + +type dualWriteContext struct { + updatedSecureValues common.InlineSecureValues +} + +func addToContext(ctx context.Context) context.Context { + return context.WithValue(ctx, ctxKey{}, &dualWriteContext{}) +} + +// Get the Requester from context +func SetUpdatedSecureValues(ctx context.Context, sv common.InlineSecureValues) { + u, ok := ctx.Value(ctxKey{}).(*dualWriteContext) + if !ok || u == nil { + return // OK, this can happen when things are in mode 0 (legacy only) + } + u.updatedSecureValues = sv +} + +// Get the Requester from context +func getUpdatedSecureValues(ctx context.Context) common.InlineSecureValues { + u, ok := ctx.Value(ctxKey{}).(*dualWriteContext) + if !ok || u == nil { + return nil + } + return u.updatedSecureValues +}