1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-10-30 23:37:45 +02:00

Allow containers to be defined in a document.

The defined containers are built before the document build begins which allows them to be reused.
This commit is contained in:
David Steele
2018-07-23 07:49:15 -04:00
parent ae72772e5b
commit 2723831032
4 changed files with 72 additions and 1 deletions

View File

@@ -39,6 +39,8 @@ use pgBackRest::Storage::Local;
use pgBackRest::Storage::Posix::Driver;
use pgBackRest::Version;
use pgBackRestTest::Common::ExecuteTest;
####################################################################################################################################
# Usage
####################################################################################################################################
@@ -244,6 +246,36 @@ eval
}
}
# Build host containers
if (!$bCacheOnly && !$bNoExe)
{
foreach my $strSource ($oManifest->sourceList())
{
if ((@stryInclude == 0 || grep(/$strSource/, @stryInclude)) && !grep(/$strSource/, @stryExclude))
{
&log(INFO, "source $strSource");
foreach my $oHostDefine ($oManifest->sourceGet($strSource)->{doc}->nodeList('host-define', false))
{
if ($oManifest->keywordMatch($oHostDefine->paramGet('keyword', false)))
{
my $strImage = $oManifest->variableReplace($oHostDefine->paramGet('image'));
my $strFrom = $oManifest->variableReplace($oHostDefine->paramGet('from'));
my $strDockerfile = "${strOutputPath}/doc-host.dockerfile";
&log(INFO, "Build vm '${strImage}' from '${strFrom}'");
$oStorageDoc->put(
$strDockerfile,
"FROM ${strFrom}\n\n" . trim($oManifest->variableReplace($oHostDefine->valueGet())) . "\n");
executeTest("docker build -f ${strDockerfile} -t ${strImage} ${strBasePath}");
}
}
}
}
}
# Render output
for my $strOutput (@stryOutput)
{
if (!($strOutput eq 'man' && $oManifest->isBackRest()))

View File

@@ -432,6 +432,32 @@ sub variableTest
return true;
}
####################################################################################################################################
# Get list of source documents
####################################################################################################################################
sub sourceList
{
my $self = shift;
# Assign function parameters, defaults, and log debug info
my ($strOperation) = logDebugParam(__PACKAGE__ . '->sourceList');
# Check that sources exist
my @strySource;
if (defined(${$self->{oManifest}}{source}))
{
@strySource = sort(keys(%{${$self->{oManifest}}{source}}));
}
# Return from function and log return values if any
return logDebugReturn
(
$strOperation,
{name => 'strySource', value => \@strySource}
);
}
####################################################################################################################################
# sourceGet
####################################################################################################################################

View File

@@ -1,5 +1,5 @@
<!ELEMENT doc ((description, intro, release-list, contributor-list)|(config, operation)|
(description?, variable-list?, block-define*, cleanup?, section+))>
(description?, variable-list?, host-define*, block-define*, cleanup?, section+))>
<!ATTLIST doc title CDATA #REQUIRED>
<!ATTLIST doc subtitle CDATA "">
<!ATTLIST doc toc CDATA "y">
@@ -187,6 +187,11 @@
<!ATTLIST support title CDATA #REQUIRED>
<!-- Host elements -->
<!ELEMENT host-define (#PCDATA)>
<!ATTLIST host-define keyword CDATA "">
<!ATTLIST host-define image CDATA #REQUIRED>
<!ATTLIST host-define from CDATA #REQUIRED>
<!ELEMENT host-add (execute*)>
<!ATTLIST host-add id CDATA "">
<!ATTLIST host-add name CDATA #REQUIRED>

View File

@@ -81,6 +81,14 @@
</release-development-list>
</release-core-list>
<release-doc-list>
<release-development-list>
<release-item>
<p>Allow containers to be defined in a document. The defined containers are built before the document build begins which allows them to be reused.</p>
</release-item>
</release-development-list>
</release-doc-list>
<release-test-list>
<release-improvement-list>
<release-item>