APIForName returns the API with the given name for the given instance. It gives precedence to built-in APIs over project-specific dynamically created APIs.
(ctx context.Context, instanceID, name string)
| 60 | // APIForName returns the API with the given name for the given instance. |
| 61 | // It gives precedence to built-in APIs over project-specific dynamically created APIs. |
| 62 | func (r *Runtime) APIForName(ctx context.Context, instanceID, name string) (*runtimev1.API, error) { |
| 63 | if api, ok := BuiltinAPIs[name]; ok { |
| 64 | return api, nil |
| 65 | } |
| 66 | |
| 67 | ctrl, err := r.Controller(ctx, instanceID) |
| 68 | if err != nil { |
| 69 | return nil, err |
| 70 | } |
| 71 | |
| 72 | resource, err := ctrl.Get(ctx, &runtimev1.ResourceName{Kind: ResourceKindAPI, Name: name}, false) |
| 73 | if err != nil { |
| 74 | return nil, err |
| 75 | } |
| 76 | |
| 77 | return resource.GetApi(), nil |
| 78 | } |