Skip to content

Commit

Permalink
Support enum delta in diffy tool
Browse files Browse the repository at this point in the history
Diffy tool will now print out diff in enumeration values between two NSX specs

Signed-off-by: Anna Khmelnitsky <[email protected]>
  • Loading branch information
annakhm committed May 3, 2023
1 parent f5da148 commit 99956ab
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tools/diffy/diffy.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def print_ident(text, level):
class color:
PURPLE = '\033[95m'
BLUE = '\033[94m'
GREEN = '\033[92m'
END = '\033[0m'

def main():
Expand All @@ -106,6 +107,12 @@ def analyze_obj(obj, level):
analyze_obj(ref_to_def(target_map[obj][attr]["$ref"]), level + 1)
if "items" in target_map[obj][attr] and "$ref" in target_map[obj][attr]["items"]:
analyze_obj(ref_to_def(target_map[obj][attr]["items"]["$ref"]), level + 1)
if "enum" in target_map[obj][attr] and attr in baseline_map[obj]:
target_set = set(target_map[obj][attr]["enum"])
baseline_set = set(baseline_map[obj][attr]["enum"])
diff = target_set - baseline_set
if diff:
print_ident(color.GREEN + "new enum values for attribute %s: %s" % (attr, diff) + color.END, level + 1)

for attr in baseline_map[obj]:
if obj not in target_map:
Expand Down

0 comments on commit 99956ab

Please sign in to comment.