Project

General

Profile

Bug #2819 » 0001-Fixes-2819-Add-classes-to-prevent-replacement-of-lin.patch

Nicolas PERRON, 2012-11-05 15:02

View differences:

techniques/fileDistribution/checkGenericFileContent/3.0/checkGenericFileContent.st
}&
&GENERIC_FILE_CONTENT_DELETION_BOOLEAN:{deletion |"delete_lines_&i&" expression => strcmp("&deletion&", "true");
}&
&GENERIC_FILE_CONTENT_MODIFICATION_BOOLEAN:{modification |"modify_lines_&i&" expression => strcmp("&modification&", "true");
# Check that section about replacements are defined
&GENERIC_FILE_CONTENT_MODIFICATION_BOOLEAN:{modification |"replacement_enabled_&i&" expression => strcmp("&modification&", "true");
}&
"replacement_regex_defined_$(index)" expression => isvariable("generic_file_content_modification_regexp[$(index)]");
"replacement_dest_defined_$(index)" expression => isvariable("generic_file_content_modification_destination[$(index)]");
# Check that all mandatories informations are defined to permit replacement of lines
"modify_lines_$(index)" and => { "replacement_enabled_$(index)", "replacement_regex_defined_$(index)", "replacement_dest_defined_$(index)" };
"edit_content_$(index)" expression => isvariable("generic_file_content_payload[$(index)]");
"tier1" expression => "any";
"tier2" expression => isvariable("file_edit_go");
......
create => "true",
edit_defaults => rudder_empty_select("$(generic_file_content_enforced[$(index)])"),
classes => kept_if_else("content_$(index)_kept", "content_$(index)_modified", "content_$(index)_failed"),
ifvarclass => "edit_content_$(index)",
comment => "Editing $(generic_file_content_path[$(index)])...";
"$(generic_file_content_path[$(index)])"
......
ifvarclass => "content_deletion_failed_$(index)";
# Files edition - replacement
# Warn users that replacement can not be done as no target value has been defined
"@@checkGenericFileContent@@log_warn@@$(generic_file_content_uuid[$(index)])@@Line replacement regular expressions@@$(generic_file_content_path[$(index)])@@$(g.execRun)##$(g.uuid)@#The file $(generic_file_content_path[$(index)]) has no desired value for replacement defined. Skipping line replacement..."
ifvarclass => "replacement_enabled_$(index).replacement_regex_defined_$(index).!replacement_dest_defined_$(index)";
"@@checkGenericFileContent@@result_success@@$(generic_file_content_uuid[$(index)])@@Line replacement regular expressions@@$(generic_file_content_path[$(index)])@@$(g.execRun)##$(g.uuid)@#The file $(generic_file_content_path[$(index)]) was not set for any line replacement"
ifvarclass => "!modify_lines_$(index)";
(2-2/2)