1
0
Fork 0

Change data driven "str" type to represent a quoted string literal (#16516)

* Change data driven "str" type to represent a quoted string literal

* Update docs
This commit is contained in:
Ryan 2022-03-05 00:25:24 +11:00 committed by GitHub
parent f634fddd34
commit ace0603f4f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 24 additions and 10 deletions

View file

@ -19,7 +19,7 @@ def process_mapping_rule(kb_info_json, rules_key, info_dict):
return None
info_key = info_dict['info_key']
key_type = info_dict.get('value_type', 'str')
key_type = info_dict.get('value_type', 'raw')
try:
rules_value = kb_info_json[info_key]
@ -32,6 +32,8 @@ def process_mapping_rule(kb_info_json, rules_key, info_dict):
return f'{rules_key} ?= {"yes" if rules_value else "no"}'
elif key_type == 'mapping':
return '\n'.join([f'{key} ?= {value}' for key, value in rules_value.items()])
elif key_type == 'str':
return f'{rules_key} ?= "{rules_value}"'
return f'{rules_key} ?= {rules_value}'