Skip to content

Commit

Permalink
(configd/templates) solve issue when target pattern cannot be found i…
Browse files Browse the repository at this point in the history
…n the config data
  • Loading branch information
AdSchellevis committed Dec 27, 2015
1 parent c8589ad commit 1f7af31
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/opnsense/service/modules/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,10 @@ def __find_filters(self, tags):
else:
target_keys = map(lambda x: str(x), range(len(config_ptr)))
else:
# config pointer is reused when the match is exact, so we need to reset it here
# if the tag was not found.
config_ptr = None
break

if len(target_keys) == 0:
# single node, only used for string replacement in output name.
result[tag] = {tag: config_ptr}
Expand Down Expand Up @@ -222,8 +224,10 @@ def _generate(self, module_name, create_directory=True):
for target_filter in target_filters.keys():
for key in target_filters[target_filter].keys():
for filename in result_filenames.keys():
if filename.find('[%s]' % target_filter) > -1:
if target_filters[target_filter][key] is not None \
and filename.find('[%s]' % target_filter) > -1:
new_filename = filename.replace('[%s]' % target_filter, target_filters[target_filter][key])
new_filename = new_filename.replace('//', '/')
result_filenames[new_filename] = copy.deepcopy(result_filenames[filename])
result_filenames[new_filename][key] = target_filters[target_filter][key]

Expand Down

0 comments on commit 1f7af31

Please sign in to comment.