45
45
- name: ANSIBLE_VALIDATE_JSONSCHEMA_CHECK_FORMAT
46
46
vars:
47
47
- name: ansible_validate_jsonschema_check_format
48
+ suppress_output:
49
+ description:
50
+ - Suppress the fields of error output.
51
+ - It's useful when the I(criteria) is too large and the error output is not required.
52
+ - And also useful when the I(data) is too large or contains sensible info.
53
+ - Can be a boolean or a list of strings.
54
+ - If set to true, then the I(found) and I(relative_schema) will be suppressed.
55
+ - If set to a list of strings, then the fields mentioned in the list will be suppressed.
56
+ type: raw
57
+ default: false
58
+ env:
59
+ - name: ANSIBLE_VALIDATE_JSONSCHEMA_SUPPRESS_OUTPUT
60
+ vars:
61
+ - name: ansible_validate_jsonschema_suppress_output
48
62
notes:
49
63
- The value of I(data) option should be either a valid B(JSON) object or a B(JSON) string.
50
64
- The value of I(criteria) should be B(list) of B(dict) or B(list) of B(strings) and each
@@ -221,6 +235,7 @@ def _validate_jsonschema(self):
221
235
222
236
draft = self ._get_sub_plugin_options ("draft" )
223
237
check_format = self ._get_sub_plugin_options ("check_format" )
238
+ suppress_output = self ._get_sub_plugin_options ("suppress_output" )
224
239
error_messages = []
225
240
226
241
for criteria in self ._criteria :
@@ -265,6 +280,10 @@ def _validate_jsonschema(self):
265
280
if "errors" not in self ._result :
266
281
self ._result ["errors" ] = []
267
282
283
+ suppress_fields = []
284
+ if suppress_output :
285
+ suppress_fields = suppress_output if isinstance (suppress_output , list ) else ["found" , "relative_schema" ]
286
+
268
287
for validation_error in validation_errors :
269
288
if isinstance (validation_error , jsonschema .ValidationError ):
270
289
error = {
@@ -277,6 +296,10 @@ def _validate_jsonschema(self):
277
296
"validator" : validation_error .validator ,
278
297
"found" : validation_error .instance ,
279
298
}
299
+
300
+ for field in suppress_fields :
301
+ error .pop (field , None )
302
+
280
303
self ._result ["errors" ].append (error )
281
304
error_message = "At '{schema_path}' {message}. " .format (
282
305
schema_path = error ["schema_path" ],
0 commit comments