Skip to content

Commit

Permalink
address pr comment
Browse files Browse the repository at this point in the history
  • Loading branch information
efd6 committed Mar 13, 2024
1 parent 6c631a8 commit 390abde
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions x-pack/filebeat/input/http_endpoint/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ func newProgram(src string) (*program, error) {

registry, err := types.NewRegistry()
if err != nil {
return nil, fmt.Errorf("failed to create env: %v", err)
return nil, fmt.Errorf("failed to create env: %w", err)
}
env, err := cel.NewEnv(
cel.Declarations(decls.NewVar("obj", decls.Dyn)),
Expand All @@ -307,17 +307,17 @@ func newProgram(src string) (*program, error) {
cel.CustomTypeProvider(registry),
)
if err != nil {
return nil, fmt.Errorf("failed to create env: %v", err)
return nil, fmt.Errorf("failed to create env: %w", err)
}

ast, iss := env.Compile(src)
if iss.Err() != nil {
return nil, fmt.Errorf("failed compilation: %v", iss.Err())
return nil, fmt.Errorf("failed compilation: %w", iss.Err())
}

prg, err := env.Program(ast)
if err != nil {
return nil, fmt.Errorf("failed program instantiation: %v", err)
return nil, fmt.Errorf("failed program instantiation: %w", err)
}
return &program{prg: prg, ast: ast}, nil
}
Expand Down Expand Up @@ -366,10 +366,6 @@ func (p *program) eval(obj interface{}) (interface{}, error) {
}
}

func errorMessage(msg string) map[string]interface{} {
return map[string]interface{}{"error": map[string]interface{}{"message": msg}}
}

func decodeJSONArray(raw *bytes.Reader) (objs []mapstr.M, rawMessages []json.RawMessage, err error) {
dec := newJSONDecoder(raw)
token, err := dec.Token()
Expand Down

0 comments on commit 390abde

Please sign in to comment.