Skip to content

Commit c6c470f

Browse files
committed
VOER-543: Add primary key for authentication related tables
1 parent 77973aa commit c6c470f

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

pre_commit_hooks/notify_duplicate_entry.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
5454
'teams_association': ['user_uuid', 'team_uuid'],
5555
'teams_resource_permission': ['team_uuid', 'resource_name'],
5656
'label': ['uuid'],
57+
'authentication_config_rules': ['auth_type'],
58+
'authentication': ['uuid'],
59+
'user_authentication_association':
60+
['user_uuid', 'authentication_uuid'],
5761
}
5862

5963
args = vars(parser.parse_args(argv))
@@ -63,10 +67,19 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
6367
for i in range(len(filenames)):
6468
json_file = filenames[i]
6569
file_name = Path(filenames[i]).stem
66-
pkeys = table_uuid_mapping[file_name]
70+
if file_name not in table_uuid_mapping:
71+
print(
72+
f"Table {file_name} has no primary key specified to validate "
73+
f"duplicate entries. Please update the plugin code in "
74+
f"https://git.voereir.io/voereir/pre-commit-hooks"
75+
)
76+
continue
77+
78+
primary_keys = table_uuid_mapping[file_name]
6779
with open(json_file, encoding='UTF-8') as f:
6880
json_entries = json.load(f)
69-
duplicate_entries, status = _check_duplicate_entry(json_entries, pkeys)
81+
duplicate_entries, status = _check_duplicate_entry(
82+
json_entries, primary_keys)
7083

7184
if status:
7285
print(f"Duplicate entries found - {duplicate_entries} in file "

0 commit comments

Comments
 (0)