Skip to content

Commit

Permalink
[Elastic Agent] Improper casting of int64 (#26520) (#26554)
Browse files Browse the repository at this point in the history
  • Loading branch information
michalpristas committed Jun 29, 2021
1 parent 9f2bee6 commit 6b970c7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion x-pack/elastic-agent/pkg/agent/transpiler/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -716,8 +716,10 @@ func load(val reflect.Value) (Node, error) {
return loadSliceOrArray(val)
case reflect.String:
return &StrVal{value: val.Interface().(string)}, nil
case reflect.Int, reflect.Int64:
case reflect.Int:
return &IntVal{value: val.Interface().(int)}, nil
case reflect.Int64:
return &IntVal{value: int(val.Interface().(int64))}, nil
case reflect.Uint:
return &UIntVal{value: uint64(val.Interface().(uint))}, nil
case reflect.Uint64:
Expand Down
2 changes: 2 additions & 0 deletions x-pack/elastic-agent/pkg/agent/transpiler/ast_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ func TestAST(t *testing.T) {
"support integers": {
hashmap: map[string]interface{}{
"timeout": 12,
"zero": int64(0),
"range": []int{20, 30, 40},
},
ast: &AST{
Expand All @@ -121,6 +122,7 @@ func TestAST(t *testing.T) {
),
},
&Key{name: "timeout", value: &IntVal{value: 12}},
&Key{name: "zero", value: &IntVal{value: 0}},
},
},
},
Expand Down

0 comments on commit 6b970c7

Please sign in to comment.