Resolve will attempt to resolve an ID to a Name by querying the manager. Results are stored into a cache. If the `-n` flag is used in the command-line, resolution is disabled.
(ctx context.Context, t any, id string)
| 58 | // Results are stored into a cache. |
| 59 | // If the `-n` flag is used in the command-line, resolution is disabled. |
| 60 | func (r *IDResolver) Resolve(ctx context.Context, t any, id string) (string, error) { |
| 61 | if r.noResolve { |
| 62 | return id, nil |
| 63 | } |
| 64 | if name, ok := r.cache[id]; ok { |
| 65 | return name, nil |
| 66 | } |
| 67 | name, err := r.get(ctx, t, id) |
| 68 | if err != nil { |
| 69 | return "", err |
| 70 | } |
| 71 | r.cache[id] = name |
| 72 | return name, nil |
| 73 | } |