()
| 286 | } |
| 287 | |
| 288 | func (o *bindCmdOptions) parseErrorHandler() (*v1.ErrorHandlerSpec, error) { |
| 289 | errHandlMap := make(map[string]any) |
| 290 | errHandlType, errHandlValue, err := parseErrorHandlerByType(o.ErrorHandler) |
| 291 | if err != nil { |
| 292 | return nil, err |
| 293 | } |
| 294 | switch errHandlType { |
| 295 | case "none": |
| 296 | errHandlMap["none"] = nil |
| 297 | case "log": |
| 298 | errHandlMap["log"] = nil |
| 299 | case "sink": |
| 300 | sinkSpec, err := o.decode(errHandlValue, errorHandlerKey) |
| 301 | if err != nil { |
| 302 | return nil, err |
| 303 | } |
| 304 | errHandlMap["sink"] = map[string]any{ |
| 305 | "endpoint": sinkSpec, |
| 306 | } |
| 307 | default: |
| 308 | return nil, fmt.Errorf("invalid error handler type %s", o.ErrorHandler) |
| 309 | } |
| 310 | errHandlMarshalled, err := json.Marshal(&errHandlMap) |
| 311 | if err != nil { |
| 312 | return nil, err |
| 313 | } |
| 314 | |
| 315 | return &v1.ErrorHandlerSpec{RawMessage: errHandlMarshalled}, nil |
| 316 | } |
| 317 | |
| 318 | func parseErrorHandlerByType(value string) (string, string, error) { |
| 319 | errHandlSplit := strings.SplitN(value, ":", 2) |
no test coverage detected