pgbackrest.git / summary / log / commit / refs

commit    1ef27ec8c2273fce99685c9354a6778d14a54792
Author:   David Steele <david@pgmasters.net>
Date:     Mon Oct 30 14:50:35 2017 +0000

    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.


build/lib/pgBackRestBuild/Config/Build.pm | 10 ---------- doc/xml/release.xml | 10 +++++++++- lib/pgBackRest/Config/Config.pm | 10 ++++++---- lib/pgBackRest/Config/Data.pm | 14 +++----------- lib/pgBackRest/Config/Rule.pm | 12 ------------ lib/pgBackRest/Version.pm | 2 +- libc/Makefile.PL | 1 - libc/xs/config/configRule.xs | 4 ---- src/config/configRule.auto.md | 17 +---------------- src/config/configRule.h | 1 - test/src/module/config/ruleTest.c | 4 ---- 11 files changed, 20 insertions(+), 65 deletions(-) diff --git a/build/lib/pgBackRestBuild/Config/Build.pm b/build/lib/pgBackRestBuild/Config/Build.pm index 1c147917b..8d443bc13 100644 --- a/build/lib/pgBackRestBuild/Config/Build.pm +++ b/build/lib/pgBackRestBuild/Config/Build.pm @@ -81,7 +81,6 @@ use constant BLDLCL_FUNCTION_SECTION => BLDLCL_PR use constant BLDLCL_FUNCTION_SECURE => BLDLCL_PREFIX_RULE_OPTION . 'Secure'; use constant BLDLCL_FUNCTION_TYPE => BLDLCL_PREFIX_RULE_OPTION . 'Type'; use constant BLDLCL_FUNCTION_VALID => BLDLCL_PREFIX_RULE_OPTION . 'Valid'; -use constant BLDLCL_FUNCTION_VALUE_HASH => BLDLCL_PREFIX_RULE_OPTION . 'ValueHash'; #################################################################################################################################### # Build command constant maps @@ -440,14 +439,6 @@ my $rhBuild = &BLD_PARAM => [BLDLCL_PARAM_COMMANDID, BLDLCL_PARAM_OPTIONID], &BLD_TRUTH_DEFAULT => false, }, - - &BLDLCL_FUNCTION_VALUE_HASH => - { - &BLD_SUMMARY => 'is the option a true hash or just a list of keys?', - &BLD_RETURN_TYPE => CGEN_DATATYPE_BOOL, - &BLD_PARAM => [BLDLCL_PARAM_OPTIONID], - &BLD_TRUTH_DEFAULT => false, - }, }, }, }, @@ -615,7 +606,6 @@ sub buildConfig functionMatrix(BLDLCL_FUNCTION_SECTION, [$iOptionId], cfgRuleOptionSection($strOption)); functionMatrix(BLDLCL_FUNCTION_SECURE, [$iOptionId], cfgRuleOptionSecure($strOption)); functionMatrix(BLDLCL_FUNCTION_TYPE, [$iOptionId], $rhOptionTypeNameIdMap->{cfgRuleOptionType($strOption)}); - functionMatrix(BLDLCL_FUNCTION_VALUE_HASH, [$iOptionId], cfgRuleOptionValueHash($strOption)); } # Build lookup functions that are not implemented with switch statements diff --git a/doc/xml/release.xml b/doc/xml/release.xml index 8a88fef19..23b058340 100644 --- a/doc/xml/release.xml +++ b/doc/xml/release.xml @@ -11,10 +11,18 @@ <release-list> <release date="XXXX-XX-XX" version="1.26dev" title="UNDER DEVELOPMENT"> + <release-core-list> + <release-refactor-list> + <release-item> + <p>Add <id>list</id> type for options. The <id>hash</id> type was being used for lists with an additional flag (`value-hash`) to indicate that it was not really a hash.</p> + </release-item> + </release-refactor-list> + </release-core-list> + <release-test-list> <release-refactor-list> <release-item> - <p>Update Debian/Ubuntu containers to download lastest version of <file>pip</file>.</p> + <p>Update Debian/Ubuntu containers to download latest version of <file>pip</file>.</p> </release-item> </release-refactor-list> </release-test-list> diff --git a/lib/pgBackRest/Config/Config.pm b/lib/pgBackRest/Config/Config.pm index 4106ff1f4..038abbb2f 100644 --- a/lib/pgBackRest/Config/Config.pm +++ b/lib/pgBackRest/Config/Config.pm @@ -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, '='); diff --git a/lib/pgBackRest/Config/Data.pm b/lib/pgBackRest/Config/Data.pm index c033a6e1e..2482e6bbc 100644 --- a/lib/pgBackRest/Config/Data.pm +++ b/lib/pgBackRest/Config/Data.pm @@ -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})) diff --git a/lib/pgBackRest/Config/Rule.pm b/lib/pgBackRest/Config/Rule.pm index c25cef19a..c31f7f61a 100644 --- a/lib/pgBackRest/Config/Rule.pm +++ b/lib/pgBackRest/Config/Rule.pm @@ -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; diff --git a/lib/pgBackRest/Version.pm b/lib/pgBackRest/Version.pm index 5d66845c5..65d1c90ea 100644 --- a/lib/pgBackRest/Version.pm +++ b/lib/pgBackRest/Version.pm @@ -35,7 +35,7 @@ use constant BACKREST_BIN => abs_path( # Defines the current version of the BackRest executable. The version number is used to track features but does not affect what # repositories or manifests can be read - that's the job of the format number. #----------------------------------------------------------------------------------------------------------------------------------- -use constant BACKREST_VERSION => '1.25'; +use constant BACKREST_VERSION => '1.26dev'; push @EXPORT, qw(BACKREST_VERSION); # Format Format Number diff --git a/libc/Makefile.PL b/libc/Makefile.PL index 29f1505ad..f45f6b871 100644 --- a/libc/Makefile.PL +++ b/libc/Makefile.PL @@ -87,7 +87,6 @@ my $rhExport = cfgRuleOptionType cfgRuleOptionValid cfgOptionTotal - cfgRuleOptionValueHash )], }, diff --git a/libc/xs/config/configRule.xs b/libc/xs/config/configRule.xs index a3bef8368..562291d5a 100644 --- a/libc/xs/config/configRule.xs +++ b/libc/xs/config/configRule.xs @@ -121,7 +121,3 @@ cfgRuleOptionValid(commandId, optionId) U32 cfgOptionTotal() - -bool -cfgRuleOptionValueHash(optionId) - U32 optionId diff --git a/src/config/configRule.auto.md b/src/config/configRule.auto.md index 1dc0391cf..a3809f1ef 100644 --- a/src/config/configRule.auto.md +++ b/src/config/configRule.auto.md @@ -883,7 +883,7 @@ Secure options can never be passed on the commmand-line. | cfgRuleOptionType | `CFGOPT_COMPRESS_LEVEL` | `CFGOPTDEF_TYPE_INTEGER` | | cfgRuleOptionType | `CFGOPT_COMPRESS_LEVEL_NETWORK` | `CFGOPTDEF_TYPE_INTEGER` | | cfgRuleOptionType | `CFGOPT_CONFIG` | `CFGOPTDEF_TYPE_STRING` | -| cfgRuleOptionType | `CFGOPT_DB_INCLUDE` | `CFGOPTDEF_TYPE_HASH` | +| cfgRuleOptionType | `CFGOPT_DB_INCLUDE` | `CFGOPTDEF_TYPE_LIST` | | cfgRuleOptionType | `CFGOPT_DB_TIMEOUT` | `CFGOPTDEF_TYPE_FLOAT` | | cfgRuleOptionType | `CFGOPT_DB1_CMD` | `CFGOPTDEF_TYPE_STRING` | | cfgRuleOptionType | `CFGOPT_DB1_CONFIG` | `CFGOPTDEF_TYPE_STRING` | @@ -1915,18 +1915,3 @@ Permutations that return `false` are excluded for brevity. | cfgRuleOptionValid | `CFGCMD_STOP` | `CFGOPT_REPO_S3_VERIFY_SSL` | `true` | | cfgRuleOptionValid | `CFGCMD_STOP` | `CFGOPT_REPO_TYPE` | `true` | | cfgRuleOptionValid | `CFGCMD_STOP` | `CFGOPT_STANZA` | `true` | - -## cfgRuleOptionValueHash - -Is the option a true hash or just a list of keys? - -### Truth Table: - -Permutations that return `false` are excluded for brevity. - -| Function | optionId | Result | -| -------- | -------- | ------ | -| cfgRuleOptionValueHash | `CFGOPT_LINK_MAP` | `true` | -| cfgRuleOptionValueHash | `CFGOPT_RECOVERY_OPTION` | `true` | -| cfgRuleOptionValueHash | `CFGOPT_TABLESPACE_MAP` | `true` | -| cfgRuleOptionValueHash | `CFGOPT_TEST_POINT` | `true` | diff --git a/src/config/configRule.h b/src/config/configRule.h index 1ee88f191..9049868dc 100644 --- a/src/config/configRule.h +++ b/src/config/configRule.h @@ -38,6 +38,5 @@ const char *cfgRuleOptionSection(int optionId); bool cfgRuleOptionSecure(int optionId); int cfgRuleOptionType(int optionId); bool cfgRuleOptionValid(int commandId, int optionId); -bool cfgRuleOptionValueHash(int optionId); #endif diff --git a/test/src/module/config/ruleTest.c b/test/src/module/config/ruleTest.c index 0365386e2..98047bb8c 100644 --- a/test/src/module/config/ruleTest.c +++ b/test/src/module/config/ruleTest.c @@ -23,7 +23,6 @@ void testRun() cfgRuleOptionSection(optionId); cfgRuleOptionSecure(optionId); cfgRuleOptionType(optionId); - cfgRuleOptionValueHash(optionId); for (int commandId = 0; commandId < cfgCommandTotal(); commandId++) { @@ -161,9 +160,6 @@ void testRun() TEST_RESULT_BOOL(cfgRuleOptionValid(CFGCMD_BACKUP, CFGOPT_TYPE), true, "option valid"); TEST_RESULT_BOOL(cfgRuleOptionValid(CFGCMD_INFO, CFGOPT_TYPE), false, "option not valid"); - TEST_RESULT_BOOL(cfgRuleOptionValueHash(CFGOPT_LINK_MAP), true, "option is value hash"); - TEST_RESULT_BOOL(cfgRuleOptionValueHash(CFGOPT_TYPE), false, "option is not value hash"); - TEST_RESULT_STR(cfgCommandName(CFGCMD_ARCHIVE_GET), "archive-get", "command name from id"); TEST_RESULT_STR(cfgCommandName(-1), NULL, "invalid command id (lower bound)"); TEST_RESULT_STR(cfgCommandName(999999), NULL, "invalid command id (upper bound)"); [parent: f57e376c4489]