DecodeConfig looks up the registered factory for the given type and uses it to decode the tool configuration.
(ctx context.Context, resourceType string, name string, decoder *yaml.Decoder)
| 54 | // DecodeConfig looks up the registered factory for the given type and uses it |
| 55 | // to decode the tool configuration. |
| 56 | func DecodeConfig(ctx context.Context, resourceType string, name string, decoder *yaml.Decoder) (ToolConfig, error) { |
| 57 | factory, found := toolRegistry[resourceType] |
| 58 | if !found { |
| 59 | return nil, fmt.Errorf("%w: %q", ErrUnknownToolType, resourceType) |
| 60 | } |
| 61 | toolConfig, err := factory(ctx, name, decoder) |
| 62 | if err != nil { |
| 63 | return nil, fmt.Errorf("unable to parse tool %q as type %q: %w", name, resourceType, err) |
| 64 | } |
| 65 | return toolConfig, nil |
| 66 | } |
| 67 | |
| 68 | type ToolConfig interface { |
| 69 | ToolConfigType() string |
no outgoing calls
no test coverage detected