You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-08-10 22:21:39 +02:00
Add list type for options.
The hash type was being used for lists with an additional flag (`value-hash`) to indicate that it was not really a hash.
This commit is contained in:
@@ -110,7 +110,7 @@ sub configLoad
|
||||
|
||||
my $strOption = $strOptionName;
|
||||
|
||||
if (cfgRuleOptionType($iOptionId) eq CFGOPTDEF_TYPE_HASH)
|
||||
if (cfgRuleOptionType($iOptionId) eq CFGOPTDEF_TYPE_HASH || cfgRuleOptionType($iOptionId) eq CFGOPTDEF_TYPE_LIST)
|
||||
{
|
||||
$strOption .= '=s@';
|
||||
}
|
||||
@@ -563,7 +563,8 @@ sub optionValidate
|
||||
}
|
||||
}
|
||||
# Convert a list of key/value pairs to a hash
|
||||
elsif (cfgRuleOptionType($iOptionId) eq CFGOPTDEF_TYPE_HASH)
|
||||
elsif (cfgRuleOptionType($iOptionId) eq CFGOPTDEF_TYPE_HASH ||
|
||||
cfgRuleOptionType($iOptionId) eq CFGOPTDEF_TYPE_LIST)
|
||||
{
|
||||
my @oValue = ();
|
||||
|
||||
@@ -702,7 +703,8 @@ sub optionValidate
|
||||
}
|
||||
|
||||
# Set option value
|
||||
if (cfgRuleOptionType($iOptionId) eq CFGOPTDEF_TYPE_HASH && ref($strValue) eq 'ARRAY')
|
||||
if (ref($strValue) eq 'ARRAY' &&
|
||||
(cfgRuleOptionType($iOptionId) eq CFGOPTDEF_TYPE_HASH || cfgRuleOptionType($iOptionId) eq CFGOPTDEF_TYPE_LIST))
|
||||
{
|
||||
foreach my $strItem (@{$strValue})
|
||||
{
|
||||
@@ -710,7 +712,7 @@ sub optionValidate
|
||||
my $strValue;
|
||||
|
||||
# If the keys are expected to have values
|
||||
if (cfgRuleOptionValueHash($iOptionId))
|
||||
if (cfgRuleOptionType($iOptionId) eq CFGOPTDEF_TYPE_HASH)
|
||||
{
|
||||
# Check for = and make sure there is a least one character on each side
|
||||
my $iEqualPos = index($strItem, '=');
|
||||
|
@@ -409,8 +409,6 @@ use constant CFGBLDDEF_RULE_DEPEND_OPTION => 'depend-o
|
||||
push @EXPORT, qw(CFGBLDDEF_RULE_DEPEND_OPTION);
|
||||
use constant CFGBLDDEF_RULE_DEPEND_LIST => 'depend-list';
|
||||
push @EXPORT, qw(CFGBLDDEF_RULE_DEPEND_LIST);
|
||||
use constant CFGBLDDEF_RULE_HASH_VALUE => 'hash-value';
|
||||
push @EXPORT, qw(CFGBLDDEF_RULE_HASH_VALUE);
|
||||
use constant CFGBLDDEF_RULE_HINT => 'hint';
|
||||
push @EXPORT, qw(CFGBLDDEF_RULE_HINT);
|
||||
use constant CFGBLDDEF_RULE_INDEX => 'index';
|
||||
@@ -440,6 +438,8 @@ use constant CFGOPTDEF_TYPE_HASH => 'hash';
|
||||
push @EXPORT, qw(CFGOPTDEF_TYPE_HASH);
|
||||
use constant CFGOPTDEF_TYPE_INTEGER => 'integer';
|
||||
push @EXPORT, qw(CFGOPTDEF_TYPE_INTEGER);
|
||||
use constant CFGOPTDEF_TYPE_LIST => 'list';
|
||||
push @EXPORT, qw(CFGOPTDEF_TYPE_LIST);
|
||||
use constant CFGOPTDEF_TYPE_STRING => 'string';
|
||||
push @EXPORT, qw(CFGOPTDEF_TYPE_STRING);
|
||||
|
||||
@@ -1546,8 +1546,7 @@ my %hOptionRule =
|
||||
&CFGOPT_DB_INCLUDE =>
|
||||
{
|
||||
&CFGBLDDEF_RULE_SECTION => CFGDEF_SECTION_GLOBAL,
|
||||
&CFGBLDDEF_RULE_TYPE => CFGOPTDEF_TYPE_HASH,
|
||||
&CFGBLDDEF_RULE_HASH_VALUE => false,
|
||||
&CFGBLDDEF_RULE_TYPE => CFGOPTDEF_TYPE_LIST,
|
||||
&CFGBLDDEF_RULE_REQUIRED => false,
|
||||
&CFGBLDDEF_RULE_COMMAND =>
|
||||
{
|
||||
@@ -1828,13 +1827,6 @@ foreach my $strKey (sort(keys(%hOptionRule)))
|
||||
&log(ASSERT, "type is required for option '${strKey}'");
|
||||
}
|
||||
|
||||
# Hash types by default have hash values (rather than just a boolean list)
|
||||
if (!defined($hOptionRule{$strKey}{&CFGBLDDEF_RULE_HASH_VALUE}))
|
||||
{
|
||||
$hOptionRule{$strKey}{&CFGBLDDEF_RULE_HASH_VALUE} =
|
||||
$hOptionRule{$strKey}{&CFGBLDDEF_RULE_TYPE} eq CFGOPTDEF_TYPE_HASH ? true : false;
|
||||
}
|
||||
|
||||
# All boolean config options can be negated. Boolean command-line options must be marked for negation individually.
|
||||
if ($hOptionRule{$strKey}{&CFGBLDDEF_RULE_TYPE} eq CFGOPTDEF_TYPE_BOOLEAN &&
|
||||
defined($hOptionRule{$strKey}{&CFGBLDDEF_RULE_SECTION}))
|
||||
|
@@ -511,16 +511,4 @@ sub cfgRuleOptionValid
|
||||
|
||||
push @EXPORT, qw(cfgRuleOptionValid);
|
||||
|
||||
####################################################################################################################################
|
||||
# cfgRuleOptionValueHash - is the option a true hash or just a list of keys?
|
||||
####################################################################################################################################
|
||||
sub cfgRuleOptionValueHash
|
||||
{
|
||||
my $strOption = cfgOptionName(shift);
|
||||
|
||||
return $rhOptionRuleIndex->{$strOption}{&CFGBLDDEF_RULE_HASH_VALUE};
|
||||
}
|
||||
|
||||
push @EXPORT, qw(cfgRuleOptionValueHash);
|
||||
|
||||
1;
|
||||
|
Reference in New Issue
Block a user