My question originates from a large software project that has a complex configuration structure.
Something similar to:
# cfg1
$config =
{ "common" =>
{ debug => 1,
logfile => "/var/log/project.log",
path => "/opt/projects/bin",
},
"project_1" =>
{ name => "Project 1",
tasks =>
[ { name => "Prepare",
program => "p1prep",
arguments => [ "--init", '--default' ],
logfile => "/var/log/p1prep.log",
},
{ name => "Work",
program => "p1",
arguments => [ "--collect" ],
logfile => "/var/log/p1.log",
env =>
{ DISPLAY => undef,
},
},
{ name => "Wrapup",
program => "signal",
arguments => [ "p1", "finished" ],
},
]
},
"project_2" =>
{ "and" => [ "so", "on", "..." ],
},
};
A particular customer could supply her own config, e.g.
# cfg2
$config =
{ "common" =>
{ debug => 0,
logfile => "/var/log/project.log",
path => "/opt/projects/bin",
},
"project_1" =>
{ name => "Project 1",
tasks =>
[ { name => "Prepare",
program => "p1prep",
arguments => [ "--init", '--default' ],
logfile => "/var/log/p1prep.log",
},
{ name => "Work",
program => "p1",
arguments => [ "--collect", "--brief" ],
logfile => "/var/log/p1.log",
env =>
{ DISPLAY => undef,
},
},
{ name => "Wrapup",
program => "signal",
arguments => [ "p1", "finished" ],
},
]
},
"project_2" =>
{ "and" => [ "so", "on", "..." ],
},
};
But instead of supplying a full config, it suffices to supply a smaller set of modifications:
# cfgaug
$config =
{ "common" => { debug => 0 },
"project_1" =>
{ tasks =>
[ { name => "Prepare" },
{ name => "Work",
arguments => [ "--collect", "--brief" ],
},
{ name => "Wrapup" },
]
},
};
Applying #cfgaug to #cfg1 will result in #cfg2.
Since several of these augmentations are possible, the need arises to produce a single 'delta' that augments the base configuration #cfg1 to the actual state.