(ctx context.Context, runtimePath string, runtimeOptions any)
| 989 | } |
| 990 | |
| 991 | func (c *Client) RuntimeInfo(ctx context.Context, runtimePath string, runtimeOptions any) (*RuntimeInfo, error) { |
| 992 | runtime, err := c.defaultRuntime(ctx) |
| 993 | if err != nil { |
| 994 | return nil, err |
| 995 | } |
| 996 | if runtimePath != "" { |
| 997 | runtime = runtimePath |
| 998 | } |
| 999 | rr := &apitypes.RuntimeRequest{ |
| 1000 | RuntimePath: runtime, |
| 1001 | } |
| 1002 | if runtimeOptions != nil { |
| 1003 | rr.Options, err = typeurl.MarshalAnyToProto(runtimeOptions) |
| 1004 | if err != nil { |
| 1005 | return nil, fmt.Errorf("failed to marshal %T: %w", runtimeOptions, err) |
| 1006 | } |
| 1007 | } |
| 1008 | |
| 1009 | s := c.IntrospectionService() |
| 1010 | |
| 1011 | resp, err := s.PluginInfo(ctx, string(plugins.RuntimePluginV2), "task", rr) |
| 1012 | if err != nil { |
| 1013 | return nil, err |
| 1014 | } |
| 1015 | |
| 1016 | var info apitypes.RuntimeInfo |
| 1017 | if err := typeurl.UnmarshalTo(resp.Extra, &info); err != nil { |
| 1018 | return nil, fmt.Errorf("failed to get runtime info from plugin info: %w", err) |
| 1019 | } |
| 1020 | |
| 1021 | var result RuntimeInfo |
| 1022 | result.Name = info.Name |
| 1023 | if info.Version != nil { |
| 1024 | result.Version.Version = info.Version.Version |
| 1025 | result.Version.Revision = info.Version.Revision |
| 1026 | } |
| 1027 | if info.Options != nil { |
| 1028 | result.Options, err = typeurl.UnmarshalAny(info.Options) |
| 1029 | if err != nil { |
| 1030 | return nil, fmt.Errorf("failed to unmarshal RuntimeInfo.Options (%T): %w", info.Options, err) |
| 1031 | } |
| 1032 | } |
| 1033 | if info.Features != nil { |
| 1034 | result.Features, err = typeurl.UnmarshalAny(info.Features) |
| 1035 | if err != nil { |
| 1036 | return nil, fmt.Errorf("failed to unmarshal RuntimeInfo.Features (%T): %w", info.Features, err) |
| 1037 | } |
| 1038 | } |
| 1039 | result.Annotations = info.Annotations |
| 1040 | return &result, nil |
| 1041 | } |
no test coverage detected