(ctx context.Context, opts *runtime.ResolverOptions)
| 28 | } |
| 29 | |
| 30 | func newAnnotationsResolver(ctx context.Context, opts *runtime.ResolverOptions) (runtime.Resolver, error) { |
| 31 | qry := &metricsview.AnnotationsQuery{} |
| 32 | if err := mapstructureutil.WeakDecode(opts.Properties, qry); err != nil { |
| 33 | return nil, err |
| 34 | } |
| 35 | |
| 36 | ctrl, err := opts.Runtime.Controller(ctx, opts.InstanceID) |
| 37 | if err != nil { |
| 38 | return nil, err |
| 39 | } |
| 40 | |
| 41 | res, err := ctrl.Get(ctx, &runtimev1.ResourceName{Kind: runtime.ResourceKindMetricsView, Name: qry.MetricsView}, false) |
| 42 | if err != nil { |
| 43 | return nil, err |
| 44 | } |
| 45 | |
| 46 | mv := res.GetMetricsView().State.ValidSpec |
| 47 | if mv == nil { |
| 48 | return nil, fmt.Errorf("metrics view %q is invalid", res.Meta.Name.Name) |
| 49 | } |
| 50 | |
| 51 | security, err := opts.Runtime.ResolveSecurity(ctx, opts.InstanceID, opts.Claims, res) |
| 52 | if err != nil { |
| 53 | return nil, err |
| 54 | } |
| 55 | |
| 56 | var userAttrs map[string]any |
| 57 | if opts.Claims != nil { |
| 58 | userAttrs = opts.Claims.UserAttributes |
| 59 | } |
| 60 | |
| 61 | ex, err := executor.New(ctx, opts.Runtime, opts.InstanceID, mv, false, security, qry.Priority, userAttrs) |
| 62 | if err != nil { |
| 63 | return nil, err |
| 64 | } |
| 65 | |
| 66 | return &metricsAnnotationsResolver{ |
| 67 | instanceID: opts.InstanceID, |
| 68 | query: qry, |
| 69 | mv: mv, |
| 70 | executor: ex, |
| 71 | runtime: opts.Runtime, |
| 72 | claims: opts.Claims, |
| 73 | }, nil |
| 74 | } |
| 75 | |
| 76 | func (r *metricsAnnotationsResolver) Close() error { |
| 77 | r.executor.Close() |
nothing calls this directly
no test coverage detected