quattor / CAF

Perl Common Application Framework
www.quattor.org
Other
4 stars 14 forks source link

Provide with a uniform backup mechanism that doesn't litter #191

Open piojo-zz opened 8 years ago

piojo-zz commented 8 years ago

Having backups in the same directory is too brittle. Rolling back if a validation has failed implies adding code to move old files around, which has to be tested and its bugs addressed. An uniform CAF API that handled the case, like

use CAF::VersionControl;
use CAF::FileWriter;
...
my $vc = CAF::VersionControl->new();
my $f1 = CAF::FileWriter->new(...);
my $f2 = CAF::FileWriter->new(...);
$vc->add($f1, $f2);
print $f1;
$fh->close();
if (config_is_sane()) {
    $vc->commit();
} else {
    $vc->revert();
}

Or something similar. We can rely on Git directly, using GIT_DIR and GIT_WORK_TREE environment variables or use etckeeper.