summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorOran Agra <oran@redislabs.com>2022-01-18 16:00:00 +0200
committerGitHub <noreply@github.com>2022-01-18 16:00:00 +0200
commiteef9c6b0ee17fe5a42cd16a812d43864868247af (patch)
tree7d1566235d09a3f706d2932eb06a902805bac5cb /utils
parentd697daa7a5600ca82a0098bc7c857bc7167bb35e (diff)
downloadredis-eef9c6b0ee17fe5a42cd16a812d43864868247af.tar.gz
New detailed key-spec flags (RO, RW, OW, RM, ACCESS, UPDATE, INSERT, DELETE) (#10122)
The new ACL key based permissions in #9974 require the key-specs (#8324) to have more explicit flags rather than just READ and WRITE. See discussion in #10040 This PR defines two groups of flags: One about how redis internally handles the key (mutually-exclusive). The other is about the logical operation done from the user's point of view (3 mutually exclusive write flags, and one read flag, all optional). In both groups, if we can't explicitly flag something as explicit read-only, delete-only, or insert-only, we flag it as `RW` or `UPDATE`. here's the definition from the code: ``` /* Key-spec flags * * -------------- */ /* The following refer what the command actually does with the value or metadata * of the key, and not necessarily the user data or how it affects it. * Each key-spec may must have exaclty one of these. Any operation that's not * distinctly deletion, overwrite or read-only would be marked as RW. */ #define CMD_KEY_RO (1ULL<<0) /* Read-Only - Reads the value of the key, but * doesn't necessarily returns it. */ #define CMD_KEY_RW (1ULL<<1) /* Read-Write - Modifies the data stored in the * value of the key or its metadata. */ #define CMD_KEY_OW (1ULL<<2) /* Overwrite - Overwrites the data stored in * the value of the key. */ #define CMD_KEY_RM (1ULL<<3) /* Deletes the key. */ /* The follwing refer to user data inside the value of the key, not the metadata * like LRU, type, cardinality. It refers to the logical operation on the user's * data (actual input strings / TTL), being used / returned / copied / changed, * It doesn't refer to modification or returning of metadata (like type, count, * presence of data). Any write that's not INSERT or DELETE, would be an UPADTE. * Each key-spec may have one of the writes with or without access, or none: */ #define CMD_KEY_ACCESS (1ULL<<4) /* Returns, copies or uses the user data from * the value of the key. */ #define CMD_KEY_UPDATE (1ULL<<5) /* Updates data to the value, new value may * depend on the old value. */ #define CMD_KEY_INSERT (1ULL<<6) /* Adds data to the value with no chance of, * modification or deletion of existing data. */ #define CMD_KEY_DELETE (1ULL<<7) /* Explicitly deletes some content * from the value of the key. */ ``` Unrelated changes: - generate-command-code.py is only compatible with python3 (modified the shabang) - generate-command-code.py print file on json parsing error - rename `shard_channel` key-spec flag to just `channel`. - add INCOMPLETE flag in input spec of SORT and SORT_RO
Diffstat (limited to 'utils')
-rwxr-xr-xutils/generate-command-code.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/utils/generate-command-code.py b/utils/generate-command-code.py
index 513dbc0f1..44a43d7cc 100755
--- a/utils/generate-command-code.py
+++ b/utils/generate-command-code.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
import os
import glob
@@ -373,9 +373,13 @@ srcdir = os.path.abspath(os.path.dirname(os.path.abspath(__file__)) + "/../src")
print("Processing json files...")
for filename in glob.glob('%s/commands/*.json' % srcdir):
with open(filename,"r") as f:
- d = json.load(f)
- for name, desc in d.items():
- create_command(name, desc)
+ try:
+ d = json.load(f)
+ for name, desc in d.items():
+ create_command(name, desc)
+ except json.decoder.JSONDecodeError as err:
+ print("Error processing %s: %s" % (filename, err))
+ exit(1)
# Link subcommands to containers
print("Linking container command to subcommands...")