mirror of
https://github.com/open-policy-agent/opa.git
synced 2026-08-12 19:32:48 -06:00
ast: Rename UUID symbol to avoid confusion
Also remove the prefix on the cache key since it's not needed (the
type alias is enough to prevent conflicts, e.g., uuidCachingKey("X")
!= "X".)
Signed-off-by: Torin Sandall <torinsandall@gmail.com>
This commit is contained in:
+4
-4
@@ -211,8 +211,8 @@ var DefaultBuiltins = [...]*Builtin{
|
||||
// Units
|
||||
UnitsParseBytes,
|
||||
|
||||
// Uuid
|
||||
UUID,
|
||||
// UUIDs
|
||||
UUIDRFC4122,
|
||||
}
|
||||
|
||||
// BuiltinMap provides a convenient mapping of built-in names to
|
||||
@@ -990,8 +990,8 @@ var UnitsParseBytes = &Builtin{
|
||||
* Type
|
||||
*/
|
||||
|
||||
// UUID returns a version 4 uuid string
|
||||
var UUID = &Builtin{
|
||||
// UUIDRFC4122 returns a version 4 UUID string.
|
||||
var UUIDRFC4122 = &Builtin{
|
||||
Name: "uuid.rfc4122",
|
||||
Decl: types.NewFunction(
|
||||
types.Args(types.S),
|
||||
|
||||
+3
-5
@@ -13,11 +13,9 @@ import (
|
||||
|
||||
type uuidCachingKey string
|
||||
|
||||
func builtinUUID(bctx BuiltinContext, args []*ast.Term, iter func(*ast.Term) error) error {
|
||||
var cachingKey = uuidCachingKey("UUID-" + args[0].Value.String())
|
||||
|
||||
func builtinUUIDRFC4122(bctx BuiltinContext, args []*ast.Term, iter func(*ast.Term) error) error {
|
||||
var cachingKey = uuidCachingKey(args[0].Value.String())
|
||||
id, ok := bctx.Cache.Get(cachingKey)
|
||||
|
||||
var uuidv4 *ast.Term
|
||||
|
||||
if !ok {
|
||||
@@ -39,5 +37,5 @@ func builtinUUID(bctx BuiltinContext, args []*ast.Term, iter func(*ast.Term) err
|
||||
}
|
||||
|
||||
func init() {
|
||||
RegisterBuiltinFunc(ast.UUID.Name, builtinUUID)
|
||||
RegisterBuiltinFunc(ast.UUIDRFC4122.Name, builtinUUIDRFC4122)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user