(op *ipOperator, rw http.ResponseWriter, req *http.Request, err error, status int)
| 434 | } |
| 435 | |
| 436 | func handleHTTPError(op *ipOperator, rw http.ResponseWriter, req *http.Request, err error, status int) { |
| 437 | op.log.Error("http request processing failed", "method", req.Method, "path", req.URL.Path, "err", err) |
| 438 | rw.WriteHeader(status) |
| 439 | |
| 440 | body := ipoptypes.IPOperatorErrorResponse{ |
| 441 | Error: err.Error(), |
| 442 | Code: -1, |
| 443 | } |
| 444 | |
| 445 | if errors.Is(err, ipoptypes.ErrIPOperator) { |
| 446 | code := err.(ipoptypes.IPOperatorError).GetCode() |
| 447 | body.Code = code |
| 448 | } |
| 449 | |
| 450 | encoder := json.NewEncoder(rw) |
| 451 | err = encoder.Encode(body) |
| 452 | if err != nil { |
| 453 | op.log.Error("failed writing response body", "err", err) |
| 454 | } |
| 455 | } |
| 456 | |
| 457 | func newIPOperator(ctx context.Context, logger log.Logger, ns string, cfg common.OperatorConfig, ilc common.IgnoreListConfig, mllbc metallb.Client) (*ipOperator, error) { |
| 458 | kc, err := fromctx.KubeClientFromCtx(ctx) |
no test coverage detected