topdown: Add units.parse builtin (#4676)

This function works on all base decimal and binary SI units of the set:

    m, K/Ki, M/Mi, G/Gi, T/Ti, P/Pi, and E/Ei

Note: Unlike `units.parse_bytes`, this function is case sensitive.

Fixes open-policy-agent#1802.

Signed-off-by: Philip Conrad <philipaconrad@gmail.com>
This commit is contained in:
Philip Conrad
2022-05-11 10:54:51 -04:00
committed by GitHub
parent 9638ee2a22
commit 53cb5f40f9
8 changed files with 771 additions and 8 deletions
+14
View File
@@ -3627,6 +3627,20 @@
"type": "function"
}
},
{
"name": "units.parse",
"decl": {
"args": [
{
"type": "string"
}
],
"result": {
"type": "number"
},
"type": "function"
}
},
{
"name": "units.parse_bytes",
"decl": {