diff --git a/pkg/graph/setup.go b/pkg/graph/setup.go index d7249ebb4..b299aed0a 100644 --- a/pkg/graph/setup.go +++ b/pkg/graph/setup.go @@ -346,3 +346,11 @@ func getClient(ctx context.Context, kc client.Client, impersonate bool) (client. } return nil, fmt.Errorf("can't impersonate client") } + +func NewUserContext(in context.Context) context.Context { + ctx := context.TODO() + if u, ok := request.UserFrom(in); ok { + ctx = request.WithUser(ctx, u) + } + return ctx +} diff --git a/pkg/registry/meta/render/storage.go b/pkg/registry/meta/render/storage.go index fb83c41fc..bad2974f2 100644 --- a/pkg/registry/meta/render/storage.go +++ b/pkg/registry/meta/render/storage.go @@ -107,7 +107,7 @@ func (r *Storage) Create(ctx context.Context, obj runtime.Object, _ rest.Validat autoColumns = true } - bv, err := graph.RenderPageBlock(ctx, r.kc, r.oc, req.Source, req.Block, req.ConvertToTable) + bv, err := graph.RenderPageBlock(graph.NewUserContext(ctx), r.kc, r.oc, req.Source, req.Block, req.ConvertToTable) if err != nil { return nil, err } @@ -121,7 +121,7 @@ func (r *Storage) Create(ctx context.Context, obj runtime.Object, _ rest.Validat renderBlocks.Insert(string(k)) } rv, err := graph.RenderLayout( - ctx, + graph.NewUserContext(ctx), r.kc, r.oc, req.Source, diff --git a/pkg/registry/meta/renderdashboard/storage.go b/pkg/registry/meta/renderdashboard/storage.go index 0393765d2..239eff6da 100644 --- a/pkg/registry/meta/renderdashboard/storage.go +++ b/pkg/registry/meta/renderdashboard/storage.go @@ -132,7 +132,7 @@ func (r *Storage) Create(ctx context.Context, obj runtime.Object, _ rest.Validat } } - dg, err := graph.RenderDashboard(ctx, r.kc, r.oc, rd, src, req.EmbeddedLink) + dg, err := graph.RenderDashboard(graph.NewUserContext(ctx), r.kc, r.oc, rd, src, req.EmbeddedLink) if err != nil { return nil, err } diff --git a/pkg/registry/meta/resourcequery/storage.go b/pkg/registry/meta/resourcequery/storage.go index b03df2cd3..2dfa724fc 100644 --- a/pkg/registry/meta/resourcequery/storage.go +++ b/pkg/registry/meta/resourcequery/storage.go @@ -106,7 +106,7 @@ func (r *Storage) Create(ctx context.Context, obj runtime.Object, _ rest.Validat src := kmapi.NewObjectID(&out) if req.OutputFormat == rsapi.OutputFormatRef { - _, refs, err := graph.ExecRawQuery(ctx, r.kc, src.OID(), *req.Target) + _, refs, err := graph.ExecRawQuery(graph.NewUserContext(ctx), r.kc, src.OID(), *req.Target) if err != nil { return nil, err } @@ -116,7 +116,7 @@ func (r *Storage) Create(ctx context.Context, obj runtime.Object, _ rest.Validat } in.Response = &runtime.RawExtension{Raw: data} } else { - rid2, items, err := graph.ExecQuery(ctx, r.kc, src.OID(), *req.Target) + rid2, items, err := graph.ExecQuery(graph.NewUserContext(ctx), r.kc, src.OID(), *req.Target) if err != nil { return nil, err }