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

Document generator improvements.

* Allow parameters to be passed when a container is created.
* Allow /etc/hosts update to be skipped (for containers without bash).
This commit is contained in:
David Steele
2018-05-25 13:42:09 -04:00
parent 40093f160c
commit e57840d739
5 changed files with 33 additions and 6 deletions

View File

@@ -831,11 +831,18 @@ sub hostKey
$$hCacheKey{option} = $self->{oManifest}->variableReplace($oHost->paramGet('option'));
}
if (defined($oHost->paramGet('param', false)))
{
$$hCacheKey{param} = $self->{oManifest}->variableReplace($oHost->paramGet('param'));
}
if (defined($oHost->paramGet('os', false)))
{
$$hCacheKey{os} = $self->{oManifest}->variableReplace($oHost->paramGet('os'));
}
$$hCacheKey{'update-hosts'} = $oHost->paramTest('update-hosts', 'n') ? JSON::PP::false : JSON::PP::true;
# Return from function and log return values if any
return logDebugReturn
(
@@ -1023,7 +1030,7 @@ sub sectionChildProcess
$self->{oManifest}->variableReplace($oChild->paramGet('user')), $$hCacheKey{os},
defined($oChild->paramGet('mount', false)) ?
[$self->{oManifest}->variableReplace($oChild->paramGet('mount'))] : undef,
$$hCacheKey{option});
$$hCacheKey{option}, $$hCacheKey{param});
$self->{host}{$$hCacheKey{name}} = $oHost;
$self->{oManifest}->variableSet('host-' . $hCacheKey->{id} . '-ip', $oHost->{strIP}, true);
@@ -1031,7 +1038,7 @@ sub sectionChildProcess
# Add to the host group
my $oHostGroup = hostGroupGet();
$oHostGroup->hostAdd($oHost);
$oHostGroup->hostAdd($oHost, {bUpdateHosts => $$hCacheKey{'update-hosts'}});
# Execute initialize commands
foreach my $oExecute ($oChild->nodeList('execute', false))

View File

@@ -189,6 +189,8 @@
<!ATTLIST host-add user CDATA #REQUIRED>
<!ATTLIST host-add image CDATA #REQUIRED>
<!ATTLIST host-add option CDATA "">
<!ATTLIST host-add update-hosts CDATA "">
<!ATTLIST host-add param CDATA "">
<!ATTLIST host-add os CDATA "">
<!ATTLIST host-add mount CDATA "">

View File

@@ -25,6 +25,14 @@
</release-development-list>
</release-core-list>
<release-doc-list>
<release-development-list>
<release-item>
<p>Document generator improvements. Allow parameters to be passed when a container is created. Allow <file>/etc/hosts</file> update to be skipped (for containers without bash).</p>
</release-item>
</release-development-list>
</release-doc-list>
<release-test-list>
<release-development-list>
<release-item>

View File

@@ -59,18 +59,23 @@ sub hostAdd
$strOperation,
$oHost,
$rstryHostName,
$bUpdateHosts,
) =
logDebugParam
(
__PACKAGE__ . '->hostAdd', \@_,
{name => 'oHost'},
{name => 'rstryHostName', optional => true},
{name => 'bUpdateHosts', default => true, optional => true},
);
$self->{host}{$oHost->{strName}} = $oHost;
$oHost->executeSimple("echo \"\" >> /etc/hosts", undef, 'root');
$oHost->executeSimple("echo \"# Test Hosts\" >> /etc/hosts", undef, 'root');
if ($bUpdateHosts)
{
$oHost->executeSimple("echo \"\" >> /etc/hosts", undef, 'root');
$oHost->executeSimple("echo \"# Test Hosts\" >> /etc/hosts", undef, 'root');
}
my $strHostList = $oHost->{strName} . (defined($rstryHostName) ? ' ' . join(' ', @{$rstryHostName}) : '');
@@ -85,7 +90,10 @@ sub hostAdd
$oOtherHost->executeSimple("echo \"$oHost->{strIP} ${strHostList}\" >> /etc/hosts", undef, 'root');
# Add all other host IPs to this host
$oHost->executeSimple("echo \"$oOtherHost->{strIP} ${strOtherHostName}\" >> /etc/hosts", undef, 'root');
if ($bUpdateHosts)
{
$oHost->executeSimple("echo \"$oOtherHost->{strIP} ${strOtherHostName}\" >> /etc/hosts", undef, 'root');
}
}
}

View File

@@ -40,6 +40,7 @@ sub new
$self->{strOS},
$self->{stryMount},
$self->{strOption},
$self->{strParam},
) =
logDebugParam
(
@@ -51,6 +52,7 @@ sub new
{name => 'strOS', trace => true},
{name => 'stryMount', required => false, trace => true},
{name => 'strOption', required => false, trace => true},
{name => 'strParam', required => false, trace => true},
);
executeTest("docker rm -f $self->{strContainer}", {bSuppressError => true});
@@ -58,7 +60,7 @@ sub new
executeTest("docker run -itd -h $self->{strName} --name=$self->{strContainer}" .
(defined($self->{strOption}) ? ' ' . $self->{strOption} : '') .
(defined($self->{stryMount}) ? ' -v ' . join(' -v ', @{$self->{stryMount}}) : '') .
" $self->{strImage}",
" $self->{strImage} " . (defined($self->{strParam}) ? ' ' . $self->{strParam} : ''),
{bSuppressStdErr => true});
# Get IP Address