From 2445b18886b13a54a892467de1085c7a53bd04ff Mon Sep 17 00:00:00 2001 From: hirokuni-kitahara Date: Thu, 26 Oct 2023 14:02:32 +0900 Subject: [PATCH] update file object model Signed-off-by: hirokuni-kitahara --- ansible_risk_insight/model_loader.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ansible_risk_insight/model_loader.py b/ansible_risk_insight/model_loader.py index 2b3529e4..77775b6a 100644 --- a/ansible_risk_insight/model_loader.py +++ b/ansible_risk_insight/model_loader.py @@ -339,10 +339,11 @@ def load_file( error = f"File not found: {fullpath}" # try reading body as a YAML string - data = None + data_str = "" if body: try: data = yaml.safe_load(body) + data_str = json.dumps(data, separators=(",", ":")) except Exception: # ignore exception if any # because possibly this file is not a YAML file @@ -358,7 +359,7 @@ def load_file( fObj = File() fObj.name = defined_in fObj.body = body - fObj.data = data + fObj.data = data_str fObj.error = error fObj.label = label fObj.defined_in = defined_in