mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-14 11:57:48 +00:00
Change split return from []string to []interface{} (#2604)
Signed-off-by: Kumar Mallikarjuna <kumarmallikarjuna1@gmail.com>
This commit is contained in:
parent
1ebf2723b2
commit
39a0fe6632
2 changed files with 9 additions and 2 deletions
|
@ -336,7 +336,14 @@ func jpfSplit(arguments []interface{}) (interface{}, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
return strings.Split(str.String(), sep.String()), nil
|
||||
split := strings.Split(str.String(), sep.String())
|
||||
arr := make([]interface{}, len(split))
|
||||
|
||||
for i, v := range split {
|
||||
arr[i] = v
|
||||
}
|
||||
|
||||
return arr, nil
|
||||
}
|
||||
|
||||
func jpRegexReplaceAll(arguments []interface{}) (interface{}, error) {
|
||||
|
|
|
@ -128,7 +128,7 @@ func TestJMESPathFunctions_Split(t *testing.T) {
|
|||
result, err := jp.Search("")
|
||||
assert.NilError(t, err)
|
||||
|
||||
split, ok := result.([]string)
|
||||
split, ok := result.([]interface{})
|
||||
assert.Assert(t, ok)
|
||||
assert.Equal(t, split[0], "Hello")
|
||||
assert.Equal(t, split[1], "Gophers")
|
||||
|
|
Loading…
Reference in a new issue