diff --git a/build/lib/pgBackRestBuild/Config/Build.pm b/build/lib/pgBackRestBuild/Config/Build.pm index 85e065001..aa7f59bfb 100644 --- a/build/lib/pgBackRestBuild/Config/Build.pm +++ b/build/lib/pgBackRestBuild/Config/Build.pm @@ -19,7 +19,6 @@ use pgBackRestDoc::Common::String; use pgBackRestDoc::ProjectInfo; use pgBackRestBuild::Build::Common; -use pgBackRestBuild::Config::BuildDefine; use pgBackRestBuild::Config::Data; #################################################################################################################################### @@ -36,8 +35,9 @@ use constant BLDLCL_CONSTANT_OPTION_TOTAL => 'CFG_OPTI use constant BLDLCL_DATA_COMMAND_CONSTANT => '01-commandConstant'; use constant BLDLCL_DATA_COMMAND => '02-command'; -use constant BLDLCL_DATA_OPTION_CONSTANT => '03-optionConstant'; -use constant BLDLCL_DATA_OPTION => '04-option'; +use constant BLDLCL_DATA_OPTION_GROUP => '03-optionGroup'; +use constant BLDLCL_DATA_OPTION_CONSTANT => '04-optionConstant'; +use constant BLDLCL_DATA_OPTION => '05-option'; use constant BLDLCL_ENUM_COMMAND => '01-enumCommand'; use constant BLDLCL_ENUM_OPTION_GROUP => '02-enumOptionGroup'; @@ -107,6 +107,11 @@ my $rhBuild = &BLD_SUMMARY => 'Command data', }, + &BLDLCL_DATA_OPTION_GROUP => + { + &BLD_SUMMARY => 'Option group data', + }, + &BLDLCL_DATA_OPTION_CONSTANT => { &BLD_SUMMARY => 'Option constants', @@ -224,14 +229,31 @@ sub buildConfig $rhEnum = $rhBuild->{&BLD_FILE}{&BLDLCL_FILE_CONFIG}{&BLD_ENUM}{&BLDLCL_ENUM_OPTION_GROUP}; my $iGroupTotal = 0; + $strBuildSource = + 'static ConfigOptionGroupData configOptionGroupData[' . BLDLCL_CONSTANT_OPTION_GROUP_TOTAL . "] = \n" . + "{"; + foreach my $strGroup (sort(keys(%{$rhOptionGroupDefine}))) { my $strGroupEnum = buildConfigOptionGroupEnum($strGroup); push(@{$rhEnum->{&BLD_LIST}}, $strGroupEnum); + $strBuildSource .= + "\n" . + " // ${strGroupEnum}\n" . + " //" . (qw{-} x 126) . "\n" . + " {\n" . + " .name = \"" . $strGroup . "\"\n" . + " },\n"; + $iGroupTotal++; } + $strBuildSource .= + "};\n"; + + $rhBuild->{&BLD_FILE}{&BLDLCL_FILE_CONFIG}{&BLD_DATA}{&BLDLCL_DATA_OPTION_GROUP}{&BLD_SOURCE} = $strBuildSource; + # Set option total constant $rhBuild->{&BLD_FILE}{&BLDLCL_FILE_CONFIG}{&BLD_CONSTANT_GROUP}{&BLDLCL_CONSTANT_OPTION_GROUP}{&BLD_CONSTANT} {&BLDLCL_CONSTANT_OPTION_GROUP_TOTAL}{&BLD_CONSTANT_VALUE} = $iGroupTotal; @@ -253,60 +275,45 @@ sub buildConfig my $iOptionIndexTotal = $rhConfigDefine->{$strOption}{&CFGDEF_INDEX_TOTAL}; my $strOptionPrefix = $rhConfigDefine->{$strOption}{&CFGDEF_PREFIX}; - # Builds option data - for (my $iOptionIndex = 1; $iOptionIndex <= $iOptionIndexTotal; $iOptionIndex++) + # Build C enum + my $strOptionEnum = buildConfigOptionEnum($strOption); + push(@{$rhEnum->{&BLD_LIST}}, $strOptionEnum); + $rhEnum->{&BLD_VALUE}{$strOptionEnum} = $iOptionTotal; + + # Build option constant name + $strOptionConst = "CFGOPT_" . uc($strOption); + $strOptionConst =~ s/\-/_/g; + + # Add option data + $strBuildSource .= + "\n" . + " //" . (qw{-} x 126) . "\n" . + " CONFIG_OPTION\n" . + " (\n" . + " CONFIG_OPTION_NAME(\"${strOption}\")\n"; + + if ($rhConfigDefine->{$strOption}{&CFGDEF_GROUP}) { - # Build C enum - my $strOptionEnum = buildConfigOptionEnum($strOption) . ($iOptionIndex == 1 ? '' : $iOptionIndex); - push(@{$rhEnum->{&BLD_LIST}}, $strOptionEnum); - $rhEnum->{&BLD_VALUE}{$strOptionEnum} = $iOptionTotal; - - # Create the indexed version of the option name - my $strOptionIndex = defined($strOptionPrefix) ? - "${strOptionPrefix}${iOptionIndex}-" . substr($strOption, length($strOptionPrefix) + 1) : $strOption; - - # Build option constant name - $strOptionConst = "CFGOPT_" . uc($strOptionIndex); - $strOptionConst =~ s/\-/_/g; - - # Add option data $strBuildSource .= - "\n" . - " //" . (qw{-} x 126) . "\n" . - " CONFIG_OPTION\n" . - " (\n" . - " CONFIG_OPTION_NAME(\"${strOptionIndex}\")\n" . - " CONFIG_OPTION_INDEX(" . ($iOptionIndex - 1) . ")\n" . - " CONFIG_OPTION_DEFINE_ID(" . buildConfigDefineOptionEnum($strOption) . ")\n"; - - if ($rhConfigDefine->{$strOption}{&CFGDEF_GROUP}) - { - $strBuildSource .= - " CONFIG_OPTION_GROUP(true)\n" . - " CONFIG_OPTION_GROUP_ID(" . buildConfigOptionGroupEnum($rhConfigDefine->{$strOption}{&CFGDEF_GROUP}) . - ")\n"; - } - else - { - $strBuildSource .= - " CONFIG_OPTION_GROUP(false)\n"; - } - - $strBuildSource .= - " )\n"; - - - if (!$rhConfigDefine->{$strOption}{&CFGDEF_GROUP}) - { - $rhBuild->{&BLD_FILE}{&BLDLCL_FILE_CONFIG}{&BLD_CONSTANT_GROUP}{&BLDLCL_CONSTANT_OPTION}{&BLD_CONSTANT} - {$strOptionConst}{&BLD_CONSTANT_VALUE} = "\"${strOptionIndex}\"\n STRING_DECLARE(${strOptionConst}_STR);"; - - $strBuildSourceConstant .= - "STRING_EXTERN(${strOptionConst}_STR," . (' ' x (49 - length($strOptionConst))) . "${strOptionConst});\n"; - } - - $iOptionTotal += 1; + " CONFIG_OPTION_GROUP(true)\n" . + " CONFIG_OPTION_GROUP_ID(" . buildConfigOptionGroupEnum($rhConfigDefine->{$strOption}{&CFGDEF_GROUP}) . + ")\n"; } + + $strBuildSource .= + " )\n"; + + + if (!$rhConfigDefine->{$strOption}{&CFGDEF_GROUP}) + { + $rhBuild->{&BLD_FILE}{&BLDLCL_FILE_CONFIG}{&BLD_CONSTANT_GROUP}{&BLDLCL_CONSTANT_OPTION}{&BLD_CONSTANT} + {$strOptionConst}{&BLD_CONSTANT_VALUE} = "\"${strOption}\"\n STRING_DECLARE(${strOptionConst}_STR);"; + + $strBuildSourceConstant .= + "STRING_EXTERN(${strOptionConst}_STR," . (' ' x (49 - length($strOptionConst))) . "${strOptionConst});\n"; + } + + $iOptionTotal += 1; } $strBuildSource .= diff --git a/build/lib/pgBackRestBuild/Config/BuildDefine.pm b/build/lib/pgBackRestBuild/Config/BuildDefine.pm index ee89fee15..8323fd6b3 100644 --- a/build/lib/pgBackRestBuild/Config/BuildDefine.pm +++ b/build/lib/pgBackRestBuild/Config/BuildDefine.pm @@ -21,6 +21,7 @@ use pgBackRestDoc::Common::String; use pgBackRestDoc::ProjectInfo; use pgBackRestBuild::Build::Common; +use pgBackRestBuild::Config::Build; use pgBackRestBuild::Config::Data; #################################################################################################################################### @@ -32,7 +33,6 @@ use constant BLDLCL_DATA_COMMAND => '01-dataC use constant BLDLCL_DATA_OPTION => '02-dataOption'; use constant BLDLCL_ENUM_OPTION_TYPE => '02-enumOptionType'; -use constant BLDLCL_ENUM_OPTION => '03-enumOption'; #################################################################################################################################### # Definitions for constants and data to build @@ -54,12 +54,6 @@ my $rhBuild = &BLD_SUMMARY => 'Option type define', &BLD_NAME => 'ConfigDefineOptionType', }, - - &BLDLCL_ENUM_OPTION => - { - &BLD_SUMMARY => 'Option define', - &BLD_NAME => 'ConfigDefineOption', - }, }, &BLD_DATA => @@ -81,11 +75,6 @@ my $rhBuild = #################################################################################################################################### # Generate enum names #################################################################################################################################### -sub buildConfigCommandEnum -{ - return bldEnum('cfgCmd', shift) -} - sub buildConfigDefineOptionTypeEnum { return bldEnum('cfgDefOptType', shift); @@ -93,13 +82,6 @@ sub buildConfigDefineOptionTypeEnum push @EXPORT, qw(buildConfigDefineOptionTypeEnum); -sub buildConfigDefineOptionEnum -{ - return bldEnum('cfgDefOpt', shift); -} - -push @EXPORT, qw(buildConfigDefineOptionEnum); - #################################################################################################################################### # Helper function to format help text #################################################################################################################################### @@ -203,14 +185,14 @@ sub renderDepend return "${strIndent} CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST\n" . "${strIndent} (\n" . - "${strIndent} " . buildConfigDefineOptionEnum($strDependOption) . ",\n" . + "${strIndent} " . buildConfigOptionEnum($strDependOption) . ",\n" . "${strIndent} " . join(",\n${strIndent} ", bldQuoteList($ryDependList)) . "\n" . "${strIndent} )\n"; } return - "${strIndent} CFGDEFDATA_OPTION_OPTIONAL_DEPEND(" . buildConfigDefineOptionEnum($strDependOption) . ")\n"; + "${strIndent} CFGDEFDATA_OPTION_OPTIONAL_DEPEND(" . buildConfigOptionEnum($strDependOption) . ")\n"; } sub renderOptional @@ -410,7 +392,6 @@ sub buildConfigDefine # Build option constants and data #------------------------------------------------------------------------------------------------------------------------------- my $rhConfigDefine = cfgDefine(); - $rhEnum = $rhBuild->{&BLD_FILE}{&BLDLCL_FILE_DEFINE}{&BLD_ENUM}{&BLDLCL_ENUM_OPTION}; $strBuildSource = "static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST\n" . @@ -421,10 +402,6 @@ sub buildConfigDefine # Get option help my $hOptionHelp = $hConfigHelp->{&CONFIG_HELP_OPTION}{$strOption}; - # Build C enum - my $strOptionEnum = buildConfigDefineOptionEnum($strOption); - push(@{$rhEnum->{&BLD_LIST}}, $strOptionEnum); - # Build option data my $rhOption = $rhConfigDefine->{$strOption}; diff --git a/build/lib/pgBackRestBuild/Config/BuildParse.pm b/build/lib/pgBackRestBuild/Config/BuildParse.pm index 17222171d..3a17e1be8 100644 --- a/build/lib/pgBackRestBuild/Config/BuildParse.pm +++ b/build/lib/pgBackRestBuild/Config/BuildParse.pm @@ -240,12 +240,9 @@ sub buildConfigParse # Else add option to resolve order list elsif (!$rhResolved->{$strOption}) { - $rhResolved->{$strOption} = true; + push(@stryResolveOrder, buildConfigOptionEnum($strOption)); - for (my $iIndex = 0; $iIndex < $rhConfigDefine->{$strOption}{&CFGDEF_INDEX_TOTAL}; $iIndex++) - { - push(@stryResolveOrder, buildConfigOptionEnum($strOption) . ($iIndex == 0 ? '' : " + $iIndex")); - } + $rhResolved->{$strOption} = true; } } } diff --git a/build/lib/pgBackRestBuild/Config/Data.pm b/build/lib/pgBackRestBuild/Config/Data.pm index 0ac788652..52b38a819 100644 --- a/build/lib/pgBackRestBuild/Config/Data.pm +++ b/build/lib/pgBackRestBuild/Config/Data.pm @@ -127,7 +127,6 @@ use constant CFGOPT_OUTPUT => 'output'; #----------------------------------------------------------------------------------------------------------------------------------- use constant CFGOPT_EXEC_ID => 'exec-id'; use constant CFGOPT_PROCESS => 'process'; -use constant CFGOPT_HOST_ID => 'host-id'; use constant CFGOPT_REMOTE_TYPE => 'remote-type'; # Command-line only storage options @@ -186,6 +185,9 @@ use constant CFGDEF_INDEX_REPO => 1; # Prefix that must be used by all repo options that allow multiple configurations use constant CFGDEF_PREFIX_REPO => 'repo'; +# Set default repository +use constant CFGOPT_REPO => CFGDEF_PREFIX_REPO; + # Repository General use constant CFGOPT_REPO_CIPHER_TYPE => CFGDEF_PREFIX_REPO . '-cipher-type'; use constant CFGOPT_REPO_CIPHER_PASS => CFGDEF_PREFIX_REPO . '-cipher-pass'; @@ -282,6 +284,9 @@ use constant CFGDEF_INDEX_PG => 8; use constant CFGDEF_PREFIX_PG => 'pg'; push @EXPORT, qw(CFGDEF_PREFIX_PG); +# Set default PostgreSQL cluster +use constant CFGOPT_PG => CFGDEF_PREFIX_PG; + use constant CFGOPT_PG_LOCAL => CFGDEF_PREFIX_PG . '-local'; use constant CFGOPT_PG_HOST => CFGDEF_PREFIX_PG . '-host'; @@ -1003,22 +1008,6 @@ my %hConfigDefine = &CFGDEF_INTERNAL => true, }, - &CFGOPT_HOST_ID => - { - &CFGDEF_TYPE => CFGDEF_TYPE_INTEGER, - &CFGDEF_REQUIRED => false, - &CFGDEF_INTERNAL => true, - &CFGDEF_ALLOW_RANGE => [1, CFGDEF_INDEX_PG > CFGDEF_INDEX_REPO ? CFGDEF_INDEX_PG : CFGDEF_INDEX_REPO], - &CFGDEF_COMMAND => - { - &CFGCMD_ARCHIVE_GET => {}, - &CFGCMD_ARCHIVE_PUSH => {}, - &CFGCMD_BACKUP => {}, - &CFGCMD_RESTORE => {}, - &CFGCMD_VERIFY => {}, - }, - }, - &CFGOPT_PROCESS => { &CFGDEF_TYPE => CFGDEF_TYPE_INTEGER, @@ -1491,6 +1480,18 @@ my %hConfigDefine = } }, + # Repository selector + #------------------------------------------------------------------------------------------------------------------------------- + &CFGOPT_REPO => + { + &CFGDEF_SECTION => CFGDEF_SECTION_GLOBAL, + &CFGDEF_TYPE => CFGDEF_TYPE_INTEGER, + &CFGDEF_INTERNAL => true, + &CFGDEF_REQUIRED => false, + &CFGDEF_ALLOW_RANGE => [1, CFGDEF_INDEX_REPO], + &CFGDEF_COMMAND => CFGOPT_REPO_TYPE, + }, + # Repository options #------------------------------------------------------------------------------------------------------------------------------- &CFGOPT_REPO_CIPHER_PASS => @@ -2574,6 +2575,37 @@ my %hConfigDefine = # Stanza options #------------------------------------------------------------------------------------------------------------------------------- + &CFGOPT_PG => + { + &CFGDEF_SECTION => CFGDEF_SECTION_STANZA, + &CFGDEF_TYPE => CFGDEF_TYPE_INTEGER, + &CFGDEF_INTERNAL => true, + &CFGDEF_REQUIRED => false, + &CFGDEF_ALLOW_RANGE => [1, CFGDEF_INDEX_PG], + &CFGDEF_COMMAND => + { + &CFGCMD_ARCHIVE_GET => {}, + &CFGCMD_ARCHIVE_PUSH => {}, + &CFGCMD_BACKUP => + { + &CFGDEF_INTERNAL => true, + }, + &CFGCMD_CHECK => + { + &CFGDEF_INTERNAL => true, + }, + &CFGCMD_RESTORE => {}, + &CFGCMD_STANZA_CREATE => + { + &CFGDEF_INTERNAL => true, + }, + &CFGCMD_STANZA_UPGRADE => + { + &CFGDEF_INTERNAL => true, + }, + }, + }, + &CFGOPT_PG_LOCAL => { &CFGDEF_GROUP => CFGOPTGRP_PG, diff --git a/doc/xml/reference.xml b/doc/xml/reference.xml index a1a28bfc1..6a6098232 100644 --- a/doc/xml/reference.xml +++ b/doc/xml/reference.xml @@ -481,6 +481,19 @@ y + + + Set default repository. + + Set the repository for a command to operate on. + + For example, this option may be used to perform a restore from a specific repository, rather than letting choose. + + Note that some commands, e.g. archive-push, are intended to operate on all repositories and will ignore this option. + + 1 + + Path where backups and archive are stored. @@ -1036,6 +1049,19 @@ db_owner + + + Set PostgreSQL cluster. + + Set the cluster for a command to operate on. + + For example, this option may be used to perform a restore to a specific cluster, rather than using the first configured cluster. + + Note that some commands, e.g. backup, are intended to operate on multiple clusters and will ignore this option. + + 1 + + data directory. diff --git a/doc/xml/release.xml b/doc/xml/release.xml index ddfe9b22c..dcf1040de 100644 --- a/doc/xml/release.xml +++ b/doc/xml/release.xml @@ -84,19 +84,32 @@ + + + + + + + + + + + + + + + + + + + + + -

Add option groups.

-
- - - - - - -

Use zero-based indexes when referring to option indexes.

+

Prepare configuration module for multi-repository support.

@@ -116,6 +129,14 @@

Allow multiple remote locks from the same main process.

+ + + + + +

Allow multiple remote locks from the same main process.

+
+ diff --git a/src/command/backup/backup.c b/src/command/backup/backup.c index 35b5fcf09..c6bb18f36 100644 --- a/src/command/backup/backup.c +++ b/src/command/backup/backup.c @@ -238,13 +238,13 @@ backupInit(const InfoBackup *infoBackup) result->pgIdxStandby = dbInfo.standbyIdx; result->dbStandby = dbInfo.standby; result->storageStandby = storagePgIdx(result->pgIdxStandby); - result->hostStandby = cfgOptionStrNull(cfgOptPgHost + result->pgIdxStandby); + result->hostStandby = cfgOptionIdxStrNull(cfgOptPgHost, result->pgIdxStandby); } } // Add primary info result->storagePrimary = storagePgIdx(result->pgIdxPrimary); - result->hostPrimary = cfgOptionStrNull(cfgOptPgHost + result->pgIdxPrimary); + result->hostPrimary = cfgOptionIdxStrNull(cfgOptPgHost, result->pgIdxPrimary); // Get pg_control info from the primary PgControl pgControl = pgControlFromFile(result->storagePrimary); diff --git a/src/command/check/check.c b/src/command/check/check.c index 069c81d81..5fcae714a 100644 --- a/src/command/check/check.c +++ b/src/command/check/check.c @@ -32,12 +32,9 @@ checkManifest(void) // Loop through all defined databases and attempt to build a manifest for (unsigned int pgIdx = 0; pgIdx < cfgOptionGroupIdxTotal(cfgOptGrpPg); pgIdx++) { - if (cfgOptionGroupIdxTest(cfgOptGrpPg, pgIdx)) - { - result++; - // ??? Placeholder for manifest build - storageListP(storagePgIdx(pgIdx), varStr(cfgOption(cfgOptPgPath + pgIdx))); - } + result++; + // ??? Placeholder for manifest build + storageListP(storagePgIdx(pgIdx), cfgOptionIdxStr(cfgOptPgPath, pgIdx)); } } MEM_CONTEXT_TEMP_END(); @@ -60,7 +57,7 @@ checkStandby(const DbGetResult dbGroup, unsigned int pgPathDefinedTotal) if (dbGroup.primary == NULL) { // If the repo is local or more than one pg-path is found then a master should have been found so error - if (repoIsLocal() || pgPathDefinedTotal > 1) + if (repoIsLocal(cfgOptionGroupIdxDefault(cfgOptGrpRepo)) || pgPathDefinedTotal > 1) { THROW( ConfigError, diff --git a/src/command/check/common.c b/src/command/check/common.c index ef289be56..ce882c867 100644 --- a/src/command/check/common.c +++ b/src/command/check/common.c @@ -57,16 +57,16 @@ checkDbConfig(const unsigned int pgVersion, const unsigned int pgIdx, const Db * { unsigned int dbVersion = dbPgVersion(dbObject); const String *dbPath = dbPgDataPath(dbObject); - unsigned int pgPath = cfgOptPgPath + pgIdx; // Error if the version from the control file and the configured pg-path do not match the values obtained from the database - if (pgVersion != dbVersion || strCmp(cfgOptionStr(pgPath), dbPath) != 0) + if (pgVersion != dbVersion || strCmp(cfgOptionIdxStr(cfgOptPgPath, pgIdx), dbPath) != 0) { THROW_FMT( DbMismatchError, "version '%s' and path '%s' queried from cluster do not match version '%s' and '%s' read from '%s/" PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL "'\nHINT: the %s and %s settings likely reference different clusters.", - strZ(pgVersionToStr(dbVersion)), strZ(dbPath), strZ(pgVersionToStr(pgVersion)), strZ(cfgOptionStr(pgPath)), - strZ(cfgOptionStr(pgPath)), cfgOptionName(pgPath), cfgOptionName(cfgOptPgPort + pgIdx)); + strZ(pgVersionToStr(dbVersion)), strZ(dbPath), strZ(pgVersionToStr(pgVersion)), + strZ(cfgOptionIdxStr(cfgOptPgPath, pgIdx)), strZ(cfgOptionIdxStr(cfgOptPgPath, pgIdx)), + cfgOptionIdxName(cfgOptPgPath, pgIdx), cfgOptionIdxName(cfgOptPgPort, pgIdx)); } // Check archive configuration if option is valid for the command and set diff --git a/src/command/command.c b/src/command/command.c index ef95dd98e..3355f15b1 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -12,7 +12,7 @@ Common Command Routines #include "common/stat.h" #include "common/time.h" #include "common/type/json.h" -#include "config/config.h" +#include "config/config.intern.h" #include "config/define.h" #include "version.h" @@ -76,71 +76,75 @@ cmdOption(void) // Skip the option if not valid for this command. Generally only one command runs at a time, but sometimes // commands are chained together (e.g. backup and expire) and the second command may not use all the options of // the first command. Displaying them is harmless but might cause confusion. - if (!cfgDefOptionValid(cfgCommand(), cfgOptionDefIdFromId(optionId))) + if (!cfgOptionValid(optionId) || !cfgDefOptionValid(cfgCommand(), optionId)) continue; - // If option was negated - if (cfgOptionNegate(optionId)) - strCatFmt(cmdOptionStr, " --no-%s", cfgOptionName(optionId)); - // If option was reset - else if (cfgOptionReset(optionId)) - strCatFmt(cmdOptionStr, " --reset-%s", cfgOptionName(optionId)); - // Else not default - else if (cfgOptionSource(optionId) != cfgSourceDefault) + // Loop through option indexes + unsigned int optionIdxTotal = cfgOptionGroup(optionId) ? cfgOptionGroupIdxTotal(cfgOptionGroupId(optionId)) : 1; + + for (unsigned int optionIdx = 0; optionIdx < optionIdxTotal; optionIdx++) { - ConfigDefineOption optionDefId = cfgOptionDefIdFromId(optionId); - - // Don't show redacted options - if (cfgDefOptionSecure(optionDefId)) - strCatFmt(cmdOptionStr, " --%s=", cfgOptionName(optionId)); - // Output boolean option - else if (cfgDefOptionType(optionDefId) == cfgDefOptTypeBoolean) - strCatFmt(cmdOptionStr, " --%s", cfgOptionName(optionId)); - // Output other options - else + // If option was negated + if (cfgOptionIdxNegate(optionId, optionIdx)) + strCatFmt(cmdOptionStr, " --no-%s", cfgOptionIdxName(optionId, optionIdx)); + // If option was reset + else if (cfgOptionIdxReset(optionId, optionIdx)) + strCatFmt(cmdOptionStr, " --reset-%s", cfgOptionIdxName(optionId, optionIdx)); + // Else not default + else if (cfgOptionIdxSource(optionId, optionIdx) != cfgSourceDefault) { - StringList *valueList = NULL; - - // Generate the values of hash options - if (cfgDefOptionType(optionDefId) == cfgDefOptTypeHash) - { - valueList = strLstNew(); - - const KeyValue *optionKv = cfgOptionKv(optionId); - const VariantList *keyList = kvKeyList(optionKv); - - for (unsigned int keyIdx = 0; keyIdx < varLstSize(keyList); keyIdx++) - { - strLstAdd( - valueList, - strNewFmt( - "%s=%s", strZ(varStr(varLstGet(keyList, keyIdx))), - strZ(varStrForce(kvGet(optionKv, varLstGet(keyList, keyIdx)))))); - } - } - // Generate values for list options - else if (cfgDefOptionType(optionDefId) == cfgDefOptTypeList) - { - valueList = strLstNewVarLst(cfgOptionLst(optionId)); - } - // Else only one value + // Don't show redacted options + if (cfgDefOptionSecure(optionId)) + strCatFmt(cmdOptionStr, " --%s=", cfgOptionIdxName(optionId, optionIdx)); + // Output boolean option + else if (cfgDefOptionType(optionId) == cfgDefOptTypeBoolean) + strCatFmt(cmdOptionStr, " --%s", cfgOptionIdxName(optionId, optionIdx)); + // Output other options else { - valueList = strLstNew(); - strLstAdd(valueList, varStrForce(cfgOption(optionId))); - } + StringList *valueList = NULL; - // Output options and values - for (unsigned int valueListIdx = 0; valueListIdx < strLstSize(valueList); valueListIdx++) - { - const String *value = strLstGet(valueList, valueListIdx); + // Generate the values of hash options + if (cfgDefOptionType(optionId) == cfgDefOptTypeHash) + { + valueList = strLstNew(); - strCatFmt(cmdOptionStr, " --%s", cfgOptionName(optionId)); + const KeyValue *optionKv = cfgOptionIdxKv(optionId, optionIdx); + const VariantList *keyList = kvKeyList(optionKv); - if (strchr(strZ(value), ' ') != NULL) - value = strNewFmt("\"%s\"", strZ(value)); + for (unsigned int keyIdx = 0; keyIdx < varLstSize(keyList); keyIdx++) + { + strLstAdd( + valueList, + strNewFmt( + "%s=%s", strZ(varStr(varLstGet(keyList, keyIdx))), + strZ(varStrForce(kvGet(optionKv, varLstGet(keyList, keyIdx)))))); + } + } + // Generate values for list options + else if (cfgDefOptionType(optionId) == cfgDefOptTypeList) + { + valueList = strLstNewVarLst(cfgOptionIdxLst(optionId, optionIdx)); + } + // Else only one value + else + { + valueList = strLstNew(); + strLstAdd(valueList, varStrForce(cfgOptionIdx(optionId, optionIdx))); + } - strCatFmt(cmdOptionStr, "=%s", strZ(value)); + // Output options and values + for (unsigned int valueListIdx = 0; valueListIdx < strLstSize(valueList); valueListIdx++) + { + const String *value = strLstGet(valueList, valueListIdx); + + strCatFmt(cmdOptionStr, " --%s", cfgOptionIdxName(optionId, optionIdx)); + + if (strchr(strZ(value), ' ') != NULL) + value = strNewFmt("\"%s\"", strZ(value)); + + strCatFmt(cmdOptionStr, "=%s", strZ(value)); + } } } } diff --git a/src/command/help/help.c b/src/command/help/help.c index 1f82c9c89..985902309 100644 --- a/src/command/help/help.c +++ b/src/command/help/help.c @@ -85,50 +85,50 @@ helpRenderValue(const Variant *value) if (value != NULL) { - if (varType(value) == varTypeBool) - { - if (varBool(value)) - result = Y_STR; - else - result = N_STR; - } - else if (varType(value) == varTypeKeyValue) - { - String *resultTemp = strNew(""); - - const KeyValue *optionKv = varKv(value); - const VariantList *keyList = kvKeyList(optionKv); - - for (unsigned int keyIdx = 0; keyIdx < varLstSize(keyList); keyIdx++) - { - if (keyIdx != 0) - strCatZ(resultTemp, ", "); - - strCatFmt( - resultTemp, "%s=%s", strZ(varStr(varLstGet(keyList, keyIdx))), - strZ(varStrForce(kvGet(optionKv, varLstGet(keyList, keyIdx))))); - } - - result = resultTemp; - } - else if (varType(value) == varTypeVariantList) - { - String *resultTemp = strNew(""); - - const VariantList *list = varVarLst(value); - - for (unsigned int listIdx = 0; listIdx < varLstSize(list); listIdx++) - { - if (listIdx != 0) - strCatZ(resultTemp, ", "); - - strCatFmt(resultTemp, "%s", strZ(varStr(varLstGet(list, listIdx)))); - } - - result = resultTemp; - } + if (varType(value) == varTypeBool) + { + if (varBool(value)) + result = Y_STR; else - result = varStrForce(value); + result = N_STR; + } + else if (varType(value) == varTypeKeyValue) + { + String *resultTemp = strNew(""); + + const KeyValue *optionKv = varKv(value); + const VariantList *keyList = kvKeyList(optionKv); + + for (unsigned int keyIdx = 0; keyIdx < varLstSize(keyList); keyIdx++) + { + if (keyIdx != 0) + strCatZ(resultTemp, ", "); + + strCatFmt( + resultTemp, "%s=%s", strZ(varStr(varLstGet(keyList, keyIdx))), + strZ(varStrForce(kvGet(optionKv, varLstGet(keyList, keyIdx))))); + } + + result = resultTemp; + } + else if (varType(value) == varTypeVariantList) + { + String *resultTemp = strNew(""); + + const VariantList *list = varVarLst(value); + + for (unsigned int listIdx = 0; listIdx < varLstSize(list); listIdx++) + { + if (listIdx != 0) + strCatZ(resultTemp, ", "); + + strCatFmt(resultTemp, "%s", strZ(varStr(varLstGet(list, listIdx)))); + } + + result = resultTemp; + } + else + result = varStrForce(value); } FUNCTION_LOG_RETURN_CONST(STRING, result); @@ -214,14 +214,14 @@ helpRender(void) KeyValue *optionKv = kvNew(); size_t optionSizeMax = 0; - for (unsigned int optionDefId = 0; optionDefId < cfgDefOptionTotal(); optionDefId++) + for (unsigned int optionId = 0; optionId < CFG_OPTION_TOTAL; optionId++) { - if (cfgDefOptionValid(commandId, optionDefId) && !cfgDefOptionInternal(commandId, optionDefId)) + if (cfgDefOptionValid(commandId, optionId) && !cfgDefOptionInternal(commandId, optionId)) { const String *section = NULL; - if (cfgDefOptionHelpSection(optionDefId) != NULL) - section = strNew(cfgDefOptionHelpSection(optionDefId)); + if (cfgDefOptionHelpSection(optionId) != NULL) + section = strNew(cfgDefOptionHelpSection(optionId)); if (section == NULL || (!strEqZ(section, "general") && !strEqZ(section, "log") && !strEqZ(section, "repository") && @@ -230,10 +230,10 @@ helpRender(void) section = strNew("command"); } - kvAdd(optionKv, VARSTR(section), VARINT((int)optionDefId)); + kvAdd(optionKv, VARSTR(section), VARINT((int)optionId)); - if (strlen(cfgDefOptionName(optionDefId)) > optionSizeMax) - optionSizeMax = strlen(cfgDefOptionName(optionDefId)); + if (strlen(cfgDefOptionName(optionId)) > optionSizeMax) + optionSizeMax = strlen(cfgDefOptionName(optionId)); } } @@ -251,13 +251,12 @@ helpRender(void) for (unsigned int optionIdx = 0; optionIdx < varLstSize(optionList); optionIdx++) { - ConfigDefineOption optionDefId = varInt(varLstGet(optionList, optionIdx)); - ConfigOption optionId = cfgOptionIdFromDefId(optionDefId, 0); + ConfigOption optionId = varInt(varLstGet(optionList, optionIdx)); // Get option summary String *summary = strFirstLower(strNewN( - cfgDefOptionHelpSummary(commandId, optionDefId), - strlen(cfgDefOptionHelpSummary(commandId, optionDefId)) - 1)); + cfgDefOptionHelpSummary(commandId, optionId), + strlen(cfgDefOptionHelpSummary(commandId, optionId)) - 1)); // Ouput current and default values if they exist const String *defaultValue = helpRenderValue(cfgOptionDefault(optionId)); @@ -271,7 +270,7 @@ helpRender(void) strCatZ(summary, " ["); if (value != NULL) - strCatFmt(summary, "current=%s", cfgDefOptionSecure(optionDefId) ? "" : strZ(value)); + strCatFmt(summary, "current=%s", cfgDefOptionSecure(optionId) ? "" : strZ(value)); if (defaultValue != NULL) { @@ -287,7 +286,7 @@ helpRender(void) // Output option help strCatFmt( result, " --%s%*s%s\n", - cfgDefOptionName(optionDefId), (int)(optionSizeMax - strlen(cfgDefOptionName(optionDefId)) + 2), "", + cfgDefOptionName(optionId), (int)(optionSizeMax - strlen(cfgDefOptionName(optionId)) + 2), "", strZ(helpRenderText(summary, optionSizeMax + 6, false, CONSOLE_WIDTH))); } } @@ -314,12 +313,10 @@ helpRender(void) if (optionId == -1) THROW_FMT(OptionInvalidError, "option '%s' is not valid for command '%s'", strZ(optionName), commandName); else - option.id = cfgOptionIdFromDefId((unsigned int)optionId, 0); + option.id = (unsigned int)optionId; } // Output option summary and description - ConfigDefineOption optionDefId = cfgOptionDefIdFromId(option.id); - strCatFmt( result, " - '%s' option help\n" @@ -327,9 +324,9 @@ helpRender(void) "%s\n" "\n" "%s\n", - cfgDefOptionName(optionDefId), - strZ(helpRenderText(STR(cfgDefOptionHelpSummary(commandId, optionDefId)), 0, true, CONSOLE_WIDTH)), - strZ(helpRenderText(STR(cfgDefOptionHelpDescription(commandId, optionDefId)), 0, true, CONSOLE_WIDTH))); + cfgDefOptionName(option.id), + strZ(helpRenderText(STR(cfgDefOptionHelpSummary(commandId, option.id)), 0, true, CONSOLE_WIDTH)), + strZ(helpRenderText(STR(cfgDefOptionHelpDescription(commandId, option.id)), 0, true, CONSOLE_WIDTH))); // Ouput current and default values if they exist const String *defaultValue = helpRenderValue(cfgOptionDefault(option.id)); @@ -343,15 +340,15 @@ helpRender(void) strCat(result, LF_STR); if (value != NULL) - strCatFmt(result, "current: %s\n", cfgDefOptionSecure(optionDefId) ? "" : strZ(value)); + strCatFmt(result, "current: %s\n", cfgDefOptionSecure(option.id) ? "" : strZ(value)); if (defaultValue != NULL) strCatFmt(result, "default: %s\n", strZ(defaultValue)); } // Output alternate name (call it deprecated so the user will know not to use it) - if (cfgDefOptionHelpNameAlt(optionDefId)) - strCatFmt(result, "\ndeprecated name: %s\n", cfgDefOptionHelpNameAltValue(optionDefId, 0)); + if (cfgDefOptionHelpNameAlt(option.id)) + strCatFmt(result, "\ndeprecated name: %s\n", cfgDefOptionHelpNameAltValue(option.id, 0)); } } diff --git a/src/common/type/stringz.h b/src/common/type/stringz.h index 7b193c2ef..a2f83d3c4 100644 --- a/src/common/type/stringz.h +++ b/src/common/type/stringz.h @@ -26,6 +26,7 @@ Zero-terminated strings that are generally useful #define LF_Z "\n" #define N_Z "n" #define NULL_Z "null" +#define ONE_Z "1" #define QUESTION_Z "?" #define QUOTED_Z "\"" #define TRUE_Z "true" diff --git a/src/config/config.auto.c b/src/config/config.auto.c index cffceadd0..fbc50b61f 100644 --- a/src/config/config.auto.c +++ b/src/config/config.auto.c @@ -294,6 +294,24 @@ static ConfigCommandData configCommandData[CFG_COMMAND_TOTAL] = CONFIG_COMMAND_L ) ) +/*********************************************************************************************************************************** +Option group data +***********************************************************************************************************************************/ +static ConfigOptionGroupData configOptionGroupData[CFG_OPTION_GROUP_TOTAL] = +{ + // cfgOptGrpPg + //------------------------------------------------------------------------------------------------------------------------------ + { + .name = "pg" + }, + + // cfgOptGrpRepo + //------------------------------------------------------------------------------------------------------------------------------ + { + .name = "repo" + }, +}; + /*********************************************************************************************************************************** Option constants ***********************************************************************************************************************************/ @@ -325,7 +343,6 @@ STRING_EXTERN(CFGOPT_EXEC_ID_STR, CFGOPT_EXEC_ STRING_EXTERN(CFGOPT_EXPIRE_AUTO_STR, CFGOPT_EXPIRE_AUTO); STRING_EXTERN(CFGOPT_FILTER_STR, CFGOPT_FILTER); STRING_EXTERN(CFGOPT_FORCE_STR, CFGOPT_FORCE); -STRING_EXTERN(CFGOPT_HOST_ID_STR, CFGOPT_HOST_ID); STRING_EXTERN(CFGOPT_IGNORE_MISSING_STR, CFGOPT_IGNORE_MISSING); STRING_EXTERN(CFGOPT_IO_TIMEOUT_STR, CFGOPT_IO_TIMEOUT); STRING_EXTERN(CFGOPT_LINK_ALL_STR, CFGOPT_LINK_ALL); @@ -341,6 +358,7 @@ STRING_EXTERN(CFGOPT_MANIFEST_SAVE_THRESHOLD_STR, CFGOPT_MANIF STRING_EXTERN(CFGOPT_NEUTRAL_UMASK_STR, CFGOPT_NEUTRAL_UMASK); STRING_EXTERN(CFGOPT_ONLINE_STR, CFGOPT_ONLINE); STRING_EXTERN(CFGOPT_OUTPUT_STR, CFGOPT_OUTPUT); +STRING_EXTERN(CFGOPT_PG_STR, CFGOPT_PG); STRING_EXTERN(CFGOPT_PROCESS_STR, CFGOPT_PROCESS); STRING_EXTERN(CFGOPT_PROCESS_MAX_STR, CFGOPT_PROCESS_MAX); STRING_EXTERN(CFGOPT_PROTOCOL_TIMEOUT_STR, CFGOPT_PROTOCOL_TIMEOUT); @@ -348,6 +366,7 @@ STRING_EXTERN(CFGOPT_RAW_STR, CFGOPT_RAW); STRING_EXTERN(CFGOPT_RECOVERY_OPTION_STR, CFGOPT_RECOVERY_OPTION); STRING_EXTERN(CFGOPT_RECURSE_STR, CFGOPT_RECURSE); STRING_EXTERN(CFGOPT_REMOTE_TYPE_STR, CFGOPT_REMOTE_TYPE); +STRING_EXTERN(CFGOPT_REPO_STR, CFGOPT_REPO); STRING_EXTERN(CFGOPT_RESUME_STR, CFGOPT_RESUME); STRING_EXTERN(CFGOPT_SCK_BLOCK_STR, CFGOPT_SCK_BLOCK); STRING_EXTERN(CFGOPT_SCK_KEEP_ALIVE_STR, CFGOPT_SCK_KEEP_ALIVE); @@ -377,1244 +396,270 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST CONFIG_OPTION ( CONFIG_OPTION_NAME("archive-async") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptArchiveAsync) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("archive-check") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptArchiveCheck) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("archive-copy") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptArchiveCopy) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("archive-get-queue-max") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptArchiveGetQueueMax) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("archive-mode") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptArchiveMode) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("archive-push-queue-max") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptArchivePushQueueMax) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("archive-timeout") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptArchiveTimeout) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("backup-standby") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptBackupStandby) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("buffer-size") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptBufferSize) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("checksum-page") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptChecksumPage) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("cipher-pass") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptCipherPass) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("cmd-ssh") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptCmdSsh) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("compress") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptCompress) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("compress-level") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptCompressLevel) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("compress-level-network") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptCompressLevelNetwork) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("compress-type") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptCompressType) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("config") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptConfig) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("config-include-path") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptConfigIncludePath) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("config-path") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptConfigPath) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("db-include") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptDbInclude) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("db-timeout") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptDbTimeout) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("delta") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptDelta) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("dry-run") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptDryRun) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("exclude") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptExclude) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("exec-id") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptExecId) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("expire-auto") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptExpireAuto) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("filter") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptFilter) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("force") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptForce) - CONFIG_OPTION_GROUP(false) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("host-id") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptHostId) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("ignore-missing") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptIgnoreMissing) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("io-timeout") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptIoTimeout) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("link-all") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptLinkAll) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("link-map") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptLinkMap) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("lock-path") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptLockPath) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("log-level-console") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptLogLevelConsole) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("log-level-file") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptLogLevelFile) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("log-level-stderr") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptLogLevelStderr) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("log-path") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptLogPath) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("log-subprocess") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptLogSubprocess) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("log-timestamp") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptLogTimestamp) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("manifest-save-threshold") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptManifestSaveThreshold) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("neutral-umask") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptNeutralUmask) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("online") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptOnline) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("output") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptOutput) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("pg1-host") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHost) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg2-host") - CONFIG_OPTION_INDEX(1) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHost) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg3-host") - CONFIG_OPTION_INDEX(2) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHost) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg4-host") - CONFIG_OPTION_INDEX(3) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHost) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg5-host") - CONFIG_OPTION_INDEX(4) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHost) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg6-host") - CONFIG_OPTION_INDEX(5) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHost) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg7-host") - CONFIG_OPTION_INDEX(6) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHost) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg8-host") - CONFIG_OPTION_INDEX(7) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHost) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg1-host-cmd") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHostCmd) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg2-host-cmd") - CONFIG_OPTION_INDEX(1) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHostCmd) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg3-host-cmd") - CONFIG_OPTION_INDEX(2) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHostCmd) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg4-host-cmd") - CONFIG_OPTION_INDEX(3) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHostCmd) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg5-host-cmd") - CONFIG_OPTION_INDEX(4) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHostCmd) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg6-host-cmd") - CONFIG_OPTION_INDEX(5) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHostCmd) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg7-host-cmd") - CONFIG_OPTION_INDEX(6) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHostCmd) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg8-host-cmd") - CONFIG_OPTION_INDEX(7) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHostCmd) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg1-host-config") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHostConfig) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg2-host-config") - CONFIG_OPTION_INDEX(1) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHostConfig) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg3-host-config") - CONFIG_OPTION_INDEX(2) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHostConfig) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg4-host-config") - CONFIG_OPTION_INDEX(3) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHostConfig) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg5-host-config") - CONFIG_OPTION_INDEX(4) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHostConfig) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg6-host-config") - CONFIG_OPTION_INDEX(5) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHostConfig) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg7-host-config") - CONFIG_OPTION_INDEX(6) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHostConfig) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg8-host-config") - CONFIG_OPTION_INDEX(7) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHostConfig) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg1-host-config-include-path") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHostConfigIncludePath) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg2-host-config-include-path") - CONFIG_OPTION_INDEX(1) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHostConfigIncludePath) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg3-host-config-include-path") - CONFIG_OPTION_INDEX(2) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHostConfigIncludePath) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg4-host-config-include-path") - CONFIG_OPTION_INDEX(3) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHostConfigIncludePath) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg5-host-config-include-path") - CONFIG_OPTION_INDEX(4) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHostConfigIncludePath) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg6-host-config-include-path") - CONFIG_OPTION_INDEX(5) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHostConfigIncludePath) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg7-host-config-include-path") - CONFIG_OPTION_INDEX(6) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHostConfigIncludePath) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg8-host-config-include-path") - CONFIG_OPTION_INDEX(7) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHostConfigIncludePath) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg1-host-config-path") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHostConfigPath) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg2-host-config-path") - CONFIG_OPTION_INDEX(1) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHostConfigPath) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg3-host-config-path") - CONFIG_OPTION_INDEX(2) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHostConfigPath) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg4-host-config-path") - CONFIG_OPTION_INDEX(3) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHostConfigPath) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg5-host-config-path") - CONFIG_OPTION_INDEX(4) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHostConfigPath) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg6-host-config-path") - CONFIG_OPTION_INDEX(5) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHostConfigPath) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg7-host-config-path") - CONFIG_OPTION_INDEX(6) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHostConfigPath) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg8-host-config-path") - CONFIG_OPTION_INDEX(7) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHostConfigPath) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg1-host-port") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHostPort) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg2-host-port") - CONFIG_OPTION_INDEX(1) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHostPort) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg3-host-port") - CONFIG_OPTION_INDEX(2) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHostPort) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg4-host-port") - CONFIG_OPTION_INDEX(3) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHostPort) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg5-host-port") - CONFIG_OPTION_INDEX(4) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHostPort) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg6-host-port") - CONFIG_OPTION_INDEX(5) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHostPort) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg7-host-port") - CONFIG_OPTION_INDEX(6) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHostPort) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg8-host-port") - CONFIG_OPTION_INDEX(7) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHostPort) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg1-host-user") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHostUser) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg2-host-user") - CONFIG_OPTION_INDEX(1) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHostUser) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg3-host-user") - CONFIG_OPTION_INDEX(2) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHostUser) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg4-host-user") - CONFIG_OPTION_INDEX(3) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHostUser) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg5-host-user") - CONFIG_OPTION_INDEX(4) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHostUser) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg6-host-user") - CONFIG_OPTION_INDEX(5) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHostUser) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg7-host-user") - CONFIG_OPTION_INDEX(6) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHostUser) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg8-host-user") - CONFIG_OPTION_INDEX(7) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgHostUser) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg1-local") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgLocal) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg2-local") - CONFIG_OPTION_INDEX(1) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgLocal) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg3-local") - CONFIG_OPTION_INDEX(2) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgLocal) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg4-local") - CONFIG_OPTION_INDEX(3) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgLocal) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg5-local") - CONFIG_OPTION_INDEX(4) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgLocal) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg6-local") - CONFIG_OPTION_INDEX(5) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgLocal) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg7-local") - CONFIG_OPTION_INDEX(6) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgLocal) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg8-local") - CONFIG_OPTION_INDEX(7) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgLocal) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg1-path") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgPath) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg2-path") - CONFIG_OPTION_INDEX(1) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgPath) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg3-path") - CONFIG_OPTION_INDEX(2) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgPath) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg4-path") - CONFIG_OPTION_INDEX(3) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgPath) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg5-path") - CONFIG_OPTION_INDEX(4) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgPath) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg6-path") - CONFIG_OPTION_INDEX(5) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgPath) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg7-path") - CONFIG_OPTION_INDEX(6) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgPath) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg8-path") - CONFIG_OPTION_INDEX(7) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgPath) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg1-port") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgPort) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg2-port") - CONFIG_OPTION_INDEX(1) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgPort) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg3-port") - CONFIG_OPTION_INDEX(2) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgPort) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg4-port") - CONFIG_OPTION_INDEX(3) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgPort) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg5-port") - CONFIG_OPTION_INDEX(4) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgPort) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg6-port") - CONFIG_OPTION_INDEX(5) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgPort) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg7-port") - CONFIG_OPTION_INDEX(6) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgPort) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg8-port") - CONFIG_OPTION_INDEX(7) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgPort) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg1-socket-path") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgSocketPath) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg2-socket-path") - CONFIG_OPTION_INDEX(1) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgSocketPath) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg3-socket-path") - CONFIG_OPTION_INDEX(2) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgSocketPath) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) - ) - - //------------------------------------------------------------------------------------------------------------------------------ - CONFIG_OPTION - ( - CONFIG_OPTION_NAME("pg4-socket-path") - CONFIG_OPTION_INDEX(3) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgSocketPath) - CONFIG_OPTION_GROUP(true) - CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) + CONFIG_OPTION_NAME("pg") ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("pg5-socket-path") - CONFIG_OPTION_INDEX(4) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgSocketPath) + CONFIG_OPTION_NAME("pg-host") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) ) @@ -1622,9 +667,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("pg6-socket-path") - CONFIG_OPTION_INDEX(5) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgSocketPath) + CONFIG_OPTION_NAME("pg-host-cmd") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) ) @@ -1632,9 +675,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("pg7-socket-path") - CONFIG_OPTION_INDEX(6) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgSocketPath) + CONFIG_OPTION_NAME("pg-host-config") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) ) @@ -1642,9 +683,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("pg8-socket-path") - CONFIG_OPTION_INDEX(7) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgSocketPath) + CONFIG_OPTION_NAME("pg-host-config-include-path") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) ) @@ -1652,9 +691,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("pg1-user") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgUser) + CONFIG_OPTION_NAME("pg-host-config-path") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) ) @@ -1662,9 +699,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("pg2-user") - CONFIG_OPTION_INDEX(1) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgUser) + CONFIG_OPTION_NAME("pg-host-port") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) ) @@ -1672,9 +707,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("pg3-user") - CONFIG_OPTION_INDEX(2) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgUser) + CONFIG_OPTION_NAME("pg-host-user") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) ) @@ -1682,9 +715,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("pg4-user") - CONFIG_OPTION_INDEX(3) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgUser) + CONFIG_OPTION_NAME("pg-local") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) ) @@ -1692,9 +723,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("pg5-user") - CONFIG_OPTION_INDEX(4) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgUser) + CONFIG_OPTION_NAME("pg-path") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) ) @@ -1702,9 +731,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("pg6-user") - CONFIG_OPTION_INDEX(5) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgUser) + CONFIG_OPTION_NAME("pg-port") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) ) @@ -1712,9 +739,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("pg7-user") - CONFIG_OPTION_INDEX(6) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgUser) + CONFIG_OPTION_NAME("pg-socket-path") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) ) @@ -1722,9 +747,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("pg8-user") - CONFIG_OPTION_INDEX(7) - CONFIG_OPTION_DEFINE_ID(cfgDefOptPgUser) + CONFIG_OPTION_NAME("pg-user") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpPg) ) @@ -1733,71 +756,54 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST CONFIG_OPTION ( CONFIG_OPTION_NAME("process") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptProcess) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("process-max") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptProcessMax) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("protocol-timeout") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptProtocolTimeout) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("raw") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptRaw) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("recovery-option") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptRecoveryOption) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("recurse") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptRecurse) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("remote-type") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptRemoteType) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("repo1-azure-account") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptRepoAzureAccount) + CONFIG_OPTION_NAME("repo") + ) + + //------------------------------------------------------------------------------------------------------------------------------ + CONFIG_OPTION + ( + CONFIG_OPTION_NAME("repo-azure-account") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpRepo) ) @@ -1805,9 +811,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("repo1-azure-ca-file") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptRepoAzureCaFile) + CONFIG_OPTION_NAME("repo-azure-ca-file") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpRepo) ) @@ -1815,9 +819,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("repo1-azure-ca-path") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptRepoAzureCaPath) + CONFIG_OPTION_NAME("repo-azure-ca-path") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpRepo) ) @@ -1825,9 +827,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("repo1-azure-container") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptRepoAzureContainer) + CONFIG_OPTION_NAME("repo-azure-container") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpRepo) ) @@ -1835,9 +835,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("repo1-azure-endpoint") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptRepoAzureEndpoint) + CONFIG_OPTION_NAME("repo-azure-endpoint") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpRepo) ) @@ -1845,9 +843,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("repo1-azure-host") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptRepoAzureHost) + CONFIG_OPTION_NAME("repo-azure-host") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpRepo) ) @@ -1855,9 +851,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("repo1-azure-key") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptRepoAzureKey) + CONFIG_OPTION_NAME("repo-azure-key") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpRepo) ) @@ -1865,9 +859,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("repo1-azure-key-type") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptRepoAzureKeyType) + CONFIG_OPTION_NAME("repo-azure-key-type") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpRepo) ) @@ -1875,9 +867,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("repo1-azure-port") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptRepoAzurePort) + CONFIG_OPTION_NAME("repo-azure-port") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpRepo) ) @@ -1885,9 +875,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("repo1-azure-verify-tls") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptRepoAzureVerifyTls) + CONFIG_OPTION_NAME("repo-azure-verify-tls") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpRepo) ) @@ -1895,9 +883,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("repo1-cipher-pass") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptRepoCipherPass) + CONFIG_OPTION_NAME("repo-cipher-pass") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpRepo) ) @@ -1905,9 +891,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("repo1-cipher-type") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptRepoCipherType) + CONFIG_OPTION_NAME("repo-cipher-type") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpRepo) ) @@ -1915,9 +899,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("repo1-hardlink") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptRepoHardlink) + CONFIG_OPTION_NAME("repo-hardlink") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpRepo) ) @@ -1925,9 +907,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("repo1-host") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptRepoHost) + CONFIG_OPTION_NAME("repo-host") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpRepo) ) @@ -1935,9 +915,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("repo1-host-cmd") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptRepoHostCmd) + CONFIG_OPTION_NAME("repo-host-cmd") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpRepo) ) @@ -1945,9 +923,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("repo1-host-config") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptRepoHostConfig) + CONFIG_OPTION_NAME("repo-host-config") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpRepo) ) @@ -1955,9 +931,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("repo1-host-config-include-path") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptRepoHostConfigIncludePath) + CONFIG_OPTION_NAME("repo-host-config-include-path") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpRepo) ) @@ -1965,9 +939,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("repo1-host-config-path") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptRepoHostConfigPath) + CONFIG_OPTION_NAME("repo-host-config-path") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpRepo) ) @@ -1975,9 +947,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("repo1-host-port") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptRepoHostPort) + CONFIG_OPTION_NAME("repo-host-port") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpRepo) ) @@ -1985,9 +955,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("repo1-host-user") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptRepoHostUser) + CONFIG_OPTION_NAME("repo-host-user") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpRepo) ) @@ -1995,9 +963,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("repo1-local") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptRepoLocal) + CONFIG_OPTION_NAME("repo-local") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpRepo) ) @@ -2005,9 +971,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("repo1-path") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptRepoPath) + CONFIG_OPTION_NAME("repo-path") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpRepo) ) @@ -2015,9 +979,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("repo1-retention-archive") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptRepoRetentionArchive) + CONFIG_OPTION_NAME("repo-retention-archive") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpRepo) ) @@ -2025,9 +987,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("repo1-retention-archive-type") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptRepoRetentionArchiveType) + CONFIG_OPTION_NAME("repo-retention-archive-type") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpRepo) ) @@ -2035,9 +995,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("repo1-retention-diff") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptRepoRetentionDiff) + CONFIG_OPTION_NAME("repo-retention-diff") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpRepo) ) @@ -2045,9 +1003,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("repo1-retention-full") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptRepoRetentionFull) + CONFIG_OPTION_NAME("repo-retention-full") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpRepo) ) @@ -2055,9 +1011,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("repo1-retention-full-type") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptRepoRetentionFullType) + CONFIG_OPTION_NAME("repo-retention-full-type") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpRepo) ) @@ -2065,9 +1019,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("repo1-s3-bucket") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptRepoS3Bucket) + CONFIG_OPTION_NAME("repo-s3-bucket") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpRepo) ) @@ -2075,9 +1027,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("repo1-s3-ca-file") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptRepoS3CaFile) + CONFIG_OPTION_NAME("repo-s3-ca-file") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpRepo) ) @@ -2085,9 +1035,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("repo1-s3-ca-path") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptRepoS3CaPath) + CONFIG_OPTION_NAME("repo-s3-ca-path") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpRepo) ) @@ -2095,9 +1043,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("repo1-s3-endpoint") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptRepoS3Endpoint) + CONFIG_OPTION_NAME("repo-s3-endpoint") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpRepo) ) @@ -2105,9 +1051,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("repo1-s3-host") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptRepoS3Host) + CONFIG_OPTION_NAME("repo-s3-host") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpRepo) ) @@ -2115,9 +1059,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("repo1-s3-key") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptRepoS3Key) + CONFIG_OPTION_NAME("repo-s3-key") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpRepo) ) @@ -2125,9 +1067,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("repo1-s3-key-secret") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptRepoS3KeySecret) + CONFIG_OPTION_NAME("repo-s3-key-secret") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpRepo) ) @@ -2135,9 +1075,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("repo1-s3-key-type") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptRepoS3KeyType) + CONFIG_OPTION_NAME("repo-s3-key-type") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpRepo) ) @@ -2145,9 +1083,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("repo1-s3-port") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptRepoS3Port) + CONFIG_OPTION_NAME("repo-s3-port") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpRepo) ) @@ -2155,9 +1091,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("repo1-s3-region") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptRepoS3Region) + CONFIG_OPTION_NAME("repo-s3-region") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpRepo) ) @@ -2165,9 +1099,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("repo1-s3-role") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptRepoS3Role) + CONFIG_OPTION_NAME("repo-s3-role") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpRepo) ) @@ -2175,9 +1107,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("repo1-s3-token") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptRepoS3Token) + CONFIG_OPTION_NAME("repo-s3-token") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpRepo) ) @@ -2185,9 +1115,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("repo1-s3-uri-style") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptRepoS3UriStyle) + CONFIG_OPTION_NAME("repo-s3-uri-style") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpRepo) ) @@ -2195,9 +1123,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("repo1-s3-verify-tls") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptRepoS3VerifyTls) + CONFIG_OPTION_NAME("repo-s3-verify-tls") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpRepo) ) @@ -2205,9 +1131,7 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( - CONFIG_OPTION_NAME("repo1-type") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptRepoType) + CONFIG_OPTION_NAME("repo-type") CONFIG_OPTION_GROUP(true) CONFIG_OPTION_GROUP_ID(cfgOptGrpRepo) ) @@ -2216,170 +1140,113 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST CONFIG_OPTION ( CONFIG_OPTION_NAME("resume") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptResume) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("sck-block") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptSckBlock) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("sck-keep-alive") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptSckKeepAlive) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("set") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptSet) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("sort") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptSort) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("spool-path") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptSpoolPath) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("stanza") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptStanza) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("start-fast") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptStartFast) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("stop-auto") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptStopAuto) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("tablespace-map") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptTablespaceMap) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("tablespace-map-all") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptTablespaceMapAll) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("target") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptTarget) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("target-action") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptTargetAction) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("target-exclusive") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptTargetExclusive) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("target-timeline") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptTargetTimeline) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("tcp-keep-alive-count") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptTcpKeepAliveCount) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("tcp-keep-alive-idle") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptTcpKeepAliveIdle) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("tcp-keep-alive-interval") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptTcpKeepAliveInterval) - CONFIG_OPTION_GROUP(false) ) //------------------------------------------------------------------------------------------------------------------------------ CONFIG_OPTION ( CONFIG_OPTION_NAME("type") - CONFIG_OPTION_INDEX(0) - CONFIG_OPTION_DEFINE_ID(cfgDefOptType) - CONFIG_OPTION_GROUP(false) ) ) diff --git a/src/config/config.auto.h b/src/config/config.auto.h index 408e0f548..abb19e773 100644 --- a/src/config/config.auto.h +++ b/src/config/config.auto.h @@ -116,8 +116,6 @@ Option constants STRING_DECLARE(CFGOPT_FILTER_STR); #define CFGOPT_FORCE "force" STRING_DECLARE(CFGOPT_FORCE_STR); -#define CFGOPT_HOST_ID "host-id" - STRING_DECLARE(CFGOPT_HOST_ID_STR); #define CFGOPT_IGNORE_MISSING "ignore-missing" STRING_DECLARE(CFGOPT_IGNORE_MISSING_STR); #define CFGOPT_IO_TIMEOUT "io-timeout" @@ -148,6 +146,8 @@ Option constants STRING_DECLARE(CFGOPT_ONLINE_STR); #define CFGOPT_OUTPUT "output" STRING_DECLARE(CFGOPT_OUTPUT_STR); +#define CFGOPT_PG "pg" + STRING_DECLARE(CFGOPT_PG_STR); #define CFGOPT_PROCESS "process" STRING_DECLARE(CFGOPT_PROCESS_STR); #define CFGOPT_PROCESS_MAX "process-max" @@ -162,6 +162,8 @@ Option constants STRING_DECLARE(CFGOPT_RECURSE_STR); #define CFGOPT_REMOTE_TYPE "remote-type" STRING_DECLARE(CFGOPT_REMOTE_TYPE_STR); +#define CFGOPT_REPO "repo" + STRING_DECLARE(CFGOPT_REPO_STR); #define CFGOPT_RESUME "resume" STRING_DECLARE(CFGOPT_RESUME_STR); #define CFGOPT_SCK_BLOCK "sck-block" @@ -201,7 +203,7 @@ Option constants #define CFGOPT_TYPE "type" STRING_DECLARE(CFGOPT_TYPE_STR); -#define CFG_OPTION_TOTAL 208 +#define CFG_OPTION_TOTAL 125 /*********************************************************************************************************************************** Command enum @@ -273,7 +275,6 @@ typedef enum cfgOptExpireAuto, cfgOptFilter, cfgOptForce, - cfgOptHostId, cfgOptIgnoreMissing, cfgOptIoTimeout, cfgOptLinkAll, @@ -289,102 +290,19 @@ typedef enum cfgOptNeutralUmask, cfgOptOnline, cfgOptOutput, + cfgOptPg, cfgOptPgHost, - cfgOptPgHost2, - cfgOptPgHost3, - cfgOptPgHost4, - cfgOptPgHost5, - cfgOptPgHost6, - cfgOptPgHost7, - cfgOptPgHost8, cfgOptPgHostCmd, - cfgOptPgHostCmd2, - cfgOptPgHostCmd3, - cfgOptPgHostCmd4, - cfgOptPgHostCmd5, - cfgOptPgHostCmd6, - cfgOptPgHostCmd7, - cfgOptPgHostCmd8, cfgOptPgHostConfig, - cfgOptPgHostConfig2, - cfgOptPgHostConfig3, - cfgOptPgHostConfig4, - cfgOptPgHostConfig5, - cfgOptPgHostConfig6, - cfgOptPgHostConfig7, - cfgOptPgHostConfig8, cfgOptPgHostConfigIncludePath, - cfgOptPgHostConfigIncludePath2, - cfgOptPgHostConfigIncludePath3, - cfgOptPgHostConfigIncludePath4, - cfgOptPgHostConfigIncludePath5, - cfgOptPgHostConfigIncludePath6, - cfgOptPgHostConfigIncludePath7, - cfgOptPgHostConfigIncludePath8, cfgOptPgHostConfigPath, - cfgOptPgHostConfigPath2, - cfgOptPgHostConfigPath3, - cfgOptPgHostConfigPath4, - cfgOptPgHostConfigPath5, - cfgOptPgHostConfigPath6, - cfgOptPgHostConfigPath7, - cfgOptPgHostConfigPath8, cfgOptPgHostPort, - cfgOptPgHostPort2, - cfgOptPgHostPort3, - cfgOptPgHostPort4, - cfgOptPgHostPort5, - cfgOptPgHostPort6, - cfgOptPgHostPort7, - cfgOptPgHostPort8, cfgOptPgHostUser, - cfgOptPgHostUser2, - cfgOptPgHostUser3, - cfgOptPgHostUser4, - cfgOptPgHostUser5, - cfgOptPgHostUser6, - cfgOptPgHostUser7, - cfgOptPgHostUser8, cfgOptPgLocal, - cfgOptPgLocal2, - cfgOptPgLocal3, - cfgOptPgLocal4, - cfgOptPgLocal5, - cfgOptPgLocal6, - cfgOptPgLocal7, - cfgOptPgLocal8, cfgOptPgPath, - cfgOptPgPath2, - cfgOptPgPath3, - cfgOptPgPath4, - cfgOptPgPath5, - cfgOptPgPath6, - cfgOptPgPath7, - cfgOptPgPath8, cfgOptPgPort, - cfgOptPgPort2, - cfgOptPgPort3, - cfgOptPgPort4, - cfgOptPgPort5, - cfgOptPgPort6, - cfgOptPgPort7, - cfgOptPgPort8, cfgOptPgSocketPath, - cfgOptPgSocketPath2, - cfgOptPgSocketPath3, - cfgOptPgSocketPath4, - cfgOptPgSocketPath5, - cfgOptPgSocketPath6, - cfgOptPgSocketPath7, - cfgOptPgSocketPath8, cfgOptPgUser, - cfgOptPgUser2, - cfgOptPgUser3, - cfgOptPgUser4, - cfgOptPgUser5, - cfgOptPgUser6, - cfgOptPgUser7, - cfgOptPgUser8, cfgOptProcess, cfgOptProcessMax, cfgOptProtocolTimeout, @@ -392,6 +310,7 @@ typedef enum cfgOptRecoveryOption, cfgOptRecurse, cfgOptRemoteType, + cfgOptRepo, cfgOptRepoAzureAccount, cfgOptRepoAzureCaFile, cfgOptRepoAzureCaPath, diff --git a/src/config/config.c b/src/config/config.c index 6ff8c5c76..480c15f83 100644 --- a/src/config/config.c +++ b/src/config/config.c @@ -8,7 +8,7 @@ Command and Option Configuration #include "common/debug.h" #include "common/error.h" #include "common/memContext.h" -#include "config/config.h" +#include "config/config.intern.h" #include "config/define.h" /*********************************************************************************************************************************** @@ -52,15 +52,20 @@ typedef struct ConfigCommandData #define CONFIG_COMMAND_PARAMETER_ALLOWED(parameterAllowedParam) \ .parameterAllowed = parameterAllowedParam, +/*********************************************************************************************************************************** +Option group data +***********************************************************************************************************************************/ +typedef struct ConfigOptionGroupData +{ + const char *name; // All options in the group must be prefixed with this name +} ConfigOptionGroupData; + /*********************************************************************************************************************************** Map options names and indexes to option definitions ***********************************************************************************************************************************/ typedef struct ConfigOptionData { - const char *name; - - unsigned int index:5; - unsigned int defineId:7; + const char *name; // Option name bool group:1; // Is the option in a group? unsigned int groupId:1; // Group id if option is in a group } ConfigOptionData; @@ -71,12 +76,8 @@ typedef struct ConfigOptionData #define CONFIG_OPTION(...) \ {__VA_ARGS__}, -#define CONFIG_OPTION_INDEX(indexParam) \ - .index = indexParam, #define CONFIG_OPTION_NAME(nameParam) \ .name = nameParam, -#define CONFIG_OPTION_DEFINE_ID(defineIdParam) \ - .defineId = defineIdParam, #define CONFIG_OPTION_GROUP(groupParam) \ .group = groupParam, #define CONFIG_OPTION_GROUP_ID(groupIdParam) \ @@ -88,64 +89,27 @@ Include the automatically generated configuration data #include "config/config.auto.c" /*********************************************************************************************************************************** -Static data for the currently loaded configuration +Data for the currently loaded configuration ***********************************************************************************************************************************/ -static struct ConfigStatic -{ - MemContext *memContext; // Mem context for config data (child of top context) - - // Generally set by the command parser but can also be set by during execute to change commands, i.e. backup -> expire - ConfigCommand command; // Current command - ConfigCommandRole commandRole; // Current command role - - String *exe; // Location of the executable - bool help; // Was help requested for the command? - StringList *paramList; // Parameters passed to the command (if any) - - // Group options that are related together to allow valid and test checks across all options in the group - struct - { - bool valid; // Is option group valid for the current command? - unsigned int indexMax; // Max index in option group - unsigned int value; // Does option group index have any values? - } optionGroup[CFG_OPTION_GROUP_TOTAL]; - - // Map options names and indexes to option definitions - struct - { - bool valid:1; // Is option valid for current command? - bool negate:1; // Is the option negated? - bool reset:1; // Is the option reset? - unsigned int source:2; // Where the option came from, i.e. ConfigSource enum - - Variant *value; // Value - Variant *defaultValue; // Default value - } option[CFG_OPTION_TOTAL]; -} configStatic; +Config *configLocal = NULL; /**********************************************************************************************************************************/ void -cfgInit(void) +cfgInit(Config *config) { - FUNCTION_TEST_VOID(); + FUNCTION_TEST_BEGIN(); + FUNCTION_TEST_PARAM_P(VOID, config); + FUNCTION_TEST_END(); + + ASSERT(config != NULL); // Free the old context - if (configStatic.memContext != NULL) - memContextFree(configStatic.memContext); + if (configLocal != NULL) + memContextFree(configLocal->memContext); - // Initialize config data - configStatic = (struct ConfigStatic){.command = cfgCmdNone}; - - // Allocate configuration context as a child of the top context - MEM_CONTEXT_BEGIN(memContextTop()) - { - MEM_CONTEXT_NEW_BEGIN("configuration") - { - configStatic.memContext = MEM_CONTEXT_NEW(); - } - MEM_CONTEXT_NEW_END(); - } - MEM_CONTEXT_END(); + // Set config and move context to top so it persists for the life of the program + configLocal = config; + memContextMove(configLocal->memContext, memContextTop()); FUNCTION_TEST_RETURN_VOID(); } @@ -155,14 +119,15 @@ ConfigCommand cfgCommand(void) { FUNCTION_TEST_VOID(); - FUNCTION_TEST_RETURN(configStatic.command); + FUNCTION_TEST_RETURN(configLocal == NULL ? cfgCmdNone : configLocal->command); } ConfigCommandRole cfgCommandRole(void) { FUNCTION_TEST_VOID(); - FUNCTION_TEST_RETURN(configStatic.commandRole); + ASSERT(configLocal != NULL); + FUNCTION_TEST_RETURN(configLocal->commandRole); } void @@ -173,10 +138,11 @@ cfgCommandSet(ConfigCommand commandId, ConfigCommandRole commandRoleId) FUNCTION_TEST_PARAM(ENUM, commandRoleId); FUNCTION_TEST_END(); + ASSERT(configLocal != NULL); ASSERT(commandId <= cfgCmdNone); - configStatic.command = commandId; - configStatic.commandRole = commandRoleId; + configLocal->command = commandId; + configLocal->commandRole = commandRoleId; FUNCTION_TEST_RETURN_VOID(); } @@ -186,28 +152,16 @@ bool cfgCommandHelp(void) { FUNCTION_TEST_VOID(); - FUNCTION_TEST_RETURN(configStatic.help); -} - -void -cfgCommandHelpSet(bool help) -{ - FUNCTION_TEST_BEGIN(); - FUNCTION_TEST_PARAM(BOOL, help); - FUNCTION_TEST_END(); - - configStatic.help = help; - - FUNCTION_TEST_RETURN_VOID(); + ASSERT(configLocal != NULL); + FUNCTION_TEST_RETURN(configLocal->help); } /**********************************************************************************************************************************/ ConfigCommand -cfgCommandId(const char *commandName, bool error) +cfgCommandId(const char *commandName) { FUNCTION_TEST_BEGIN(); FUNCTION_TEST_PARAM(STRINGZ, commandName); - FUNCTION_TEST_PARAM(BOOL, error); FUNCTION_TEST_END(); ASSERT(commandName != NULL); @@ -218,9 +172,6 @@ cfgCommandId(const char *commandName, bool error) if (strcmp(commandName, configCommandData[commandId].name) == 0) break; - if (commandId == cfgCmdNone && error) - THROW_FMT(AssertError, "invalid command '%s'", commandName); - FUNCTION_TEST_RETURN(commandId); } @@ -268,34 +219,18 @@ cfgCommandParam(void) { FUNCTION_TEST_VOID(); - if (configStatic.paramList == NULL) + ASSERT(configLocal != NULL); + + if (configLocal->paramList == NULL) { - MEM_CONTEXT_BEGIN(configStatic.memContext) + MEM_CONTEXT_BEGIN(configLocal->memContext) { - configStatic.paramList = strLstNew(); + configLocal->paramList = strLstNew(); } MEM_CONTEXT_END(); } - FUNCTION_TEST_RETURN(configStatic.paramList); -} - -void -cfgCommandParamSet(const StringList *param) -{ - FUNCTION_TEST_BEGIN(); - FUNCTION_TEST_PARAM(STRING_LIST, param); - FUNCTION_TEST_END(); - - ASSERT(param != NULL); - - MEM_CONTEXT_BEGIN(configStatic.memContext) - { - configStatic.paramList = strLstDup(param); - } - MEM_CONTEXT_END(); - - FUNCTION_TEST_RETURN_VOID(); + FUNCTION_TEST_RETURN(configLocal->paramList); } /**********************************************************************************************************************************/ @@ -363,25 +298,8 @@ const String * cfgExe(void) { FUNCTION_TEST_VOID(); - FUNCTION_TEST_RETURN(configStatic.exe); -} - -void -cfgExeSet(const String *exe) -{ - FUNCTION_TEST_BEGIN(); - FUNCTION_TEST_PARAM(STRING, exe); - FUNCTION_TEST_END(); - - ASSERT(exe != NULL); - - MEM_CONTEXT_BEGIN(configStatic.memContext) - { - configStatic.exe = strDup(exe); - } - MEM_CONTEXT_END(); - - FUNCTION_TEST_RETURN_VOID(); + ASSERT(configLocal != NULL); + FUNCTION_TEST_RETURN(configLocal->exe); } /**********************************************************************************************************************************/ @@ -403,7 +321,8 @@ cfgLockRequired(void) { FUNCTION_TEST_VOID(); - ASSERT(configStatic.command != cfgCmdNone); + ASSERT(configLocal != NULL); + ASSERT(configLocal->command != cfgCmdNone); // Local roles never take a lock and the remote role has special logic for locking FUNCTION_TEST_RETURN( @@ -428,7 +347,8 @@ cfgLockType(void) { FUNCTION_TEST_VOID(); - ASSERT(configStatic.command != cfgCmdNone); + ASSERT(configLocal != NULL); + ASSERT(configLocal->command != cfgCmdNone); FUNCTION_TEST_RETURN((LockType)configCommandData[cfgCommand()].lockType); } @@ -439,13 +359,14 @@ cfgLogFile(void) { FUNCTION_TEST_VOID(); - ASSERT(configStatic.command != cfgCmdNone); + ASSERT(configLocal != NULL); + ASSERT(configLocal->command != cfgCmdNone); FUNCTION_TEST_RETURN( // If the command always logs to a file configCommandData[cfgCommand()].logFile || // Or log-level-file was explicitly set as a param/env var - cfgOptionSource(cfgOptLogLevelFile) == cfgSourceParam || + (cfgOptionValid(cfgOptLogLevelFile) && cfgOptionSource(cfgOptLogLevelFile) == cfgSourceParam) || // Or the role is async cfgCommandRole() == cfgCmdRoleAsync); } @@ -456,35 +377,114 @@ cfgLogLevelDefault(void) { FUNCTION_TEST_VOID(); - ASSERT(configStatic.command != cfgCmdNone); + ASSERT(configLocal != NULL); + ASSERT(configLocal->command != cfgCmdNone); FUNCTION_TEST_RETURN((LogLevel)configCommandData[cfgCommand()].logLevelDefault); } /**********************************************************************************************************************************/ bool -cfgParameterAllowed(void) +cfgCommandParameterAllowed(ConfigCommand commandId) { - FUNCTION_TEST_VOID(); + FUNCTION_TEST_BEGIN(); + FUNCTION_TEST_PARAM(ENUM, commandId); + FUNCTION_TEST_END(); - ASSERT(configStatic.command != cfgCmdNone); + ASSERT(commandId < cfgCmdNone); - FUNCTION_TEST_RETURN(configCommandData[cfgCommand()].parameterAllowed); + FUNCTION_TEST_RETURN(configCommandData[commandId].parameterAllowed); } /**********************************************************************************************************************************/ bool -cfgOptionGroupIdxTest(ConfigOptionGroup groupId, unsigned int index) +cfgOptionGroup(ConfigOption optionId) +{ + FUNCTION_TEST_BEGIN(); + FUNCTION_TEST_PARAM(ENUM, optionId); + FUNCTION_TEST_END(); + + ASSERT(optionId < CFG_OPTION_TOTAL); + + FUNCTION_TEST_RETURN(configOptionData[optionId].group); +} + +/**********************************************************************************************************************************/ +unsigned int +cfgOptionGroupId(ConfigOption optionId) +{ + FUNCTION_TEST_BEGIN(); + FUNCTION_TEST_PARAM(ENUM, optionId); + FUNCTION_TEST_END(); + + ASSERT(optionId < CFG_OPTION_TOTAL); + ASSERT(configOptionData[optionId].group); + + FUNCTION_TEST_RETURN(configOptionData[optionId].groupId); +} + +/**********************************************************************************************************************************/ +unsigned int +cfgOptionGroupIdxDefault(ConfigOptionGroup groupId) { FUNCTION_TEST_BEGIN(); FUNCTION_TEST_PARAM(ENUM, groupId); - FUNCTION_TEST_PARAM(UINT, index); FUNCTION_TEST_END(); + ASSERT(configLocal != NULL); ASSERT(groupId < CFG_OPTION_GROUP_TOTAL); - FUNCTION_TEST_RETURN( - cfgOptionGroupValid(groupId) && (index == 0 || configStatic.optionGroup[groupId].value & ((unsigned int)1 << index))); + FUNCTION_TEST_RETURN(configLocal->optionGroup[groupId].indexDefault); +} + +/**********************************************************************************************************************************/ +unsigned int +cfgOptionGroupIdxToKey(ConfigOptionGroup groupId, unsigned int groupIdx) +{ + FUNCTION_TEST_BEGIN(); + FUNCTION_TEST_PARAM(ENUM, groupId); + FUNCTION_TEST_PARAM(UINT, groupIdx); + FUNCTION_TEST_END(); + + ASSERT(configLocal != NULL); + ASSERT(groupId < CFG_OPTION_GROUP_TOTAL); + ASSERT(groupIdx < configLocal->optionGroup[groupId].indexTotal); + + FUNCTION_TEST_RETURN(configLocal->optionGroup[groupId].indexMap[groupIdx] + 1); +} + +/**********************************************************************************************************************************/ +unsigned int +cfgOptionKeyToIdx(ConfigOption optionId, unsigned int key) +{ + FUNCTION_TEST_BEGIN(); + FUNCTION_TEST_PARAM(ENUM, optionId); + FUNCTION_TEST_PARAM(UINT, key); + FUNCTION_TEST_END(); + + ASSERT(configLocal != NULL); + ASSERT(optionId < CFG_OPTION_TOTAL); + + unsigned int result = 0; + + // If then option is in a group then search for the key, else the index is 0 + if (cfgOptionGroup(optionId)) + { + unsigned int groupId = cfgOptionGroupId(optionId); + + // Seach the group for the key + for (; result < cfgOptionGroupIdxTotal(groupId); result++) + { + if (configLocal->optionGroup[groupId].indexMap[result] == key - 1) + break; + } + + // Error when the key is not found + if (result == cfgOptionGroupIdxTotal(groupId)) + THROW_FMT(AssertError, "key '%u' is not valid for '%s' option", key, configOptionData[optionId].name); + } + + FUNCTION_TEST_RETURN(result); } /**********************************************************************************************************************************/ @@ -495,9 +495,10 @@ cfgOptionGroupIdxTotal(ConfigOptionGroup groupId) FUNCTION_TEST_PARAM(ENUM, groupId); FUNCTION_TEST_END(); + ASSERT(configLocal != NULL); ASSERT(groupId < CFG_OPTION_GROUP_TOTAL); - FUNCTION_TEST_RETURN(cfgOptionGroupValid(groupId) ? configStatic.optionGroup[groupId].indexMax + 1 : 0); + FUNCTION_TEST_RETURN(configLocal->optionGroup[groupId].indexTotal); } /**********************************************************************************************************************************/ @@ -508,36 +509,54 @@ cfgOptionGroupValid(ConfigOptionGroup groupId) FUNCTION_TEST_PARAM(ENUM, groupId); FUNCTION_TEST_END(); + ASSERT(configLocal != NULL); ASSERT(groupId < CFG_OPTION_GROUP_TOTAL); - FUNCTION_TEST_RETURN(configStatic.optionGroup[groupId].valid); + FUNCTION_TEST_RETURN(configLocal->optionGroup[groupId].valid); } /**********************************************************************************************************************************/ -ConfigDefineOption -cfgOptionDefIdFromId(ConfigOption optionId) +unsigned int +cfgOptionIdxDefault(ConfigOption optionId) { FUNCTION_TEST_BEGIN(); FUNCTION_TEST_PARAM(ENUM, optionId); FUNCTION_TEST_END(); + ASSERT(configLocal != NULL); ASSERT(optionId < CFG_OPTION_TOTAL); - FUNCTION_TEST_RETURN(configOptionData[optionId].defineId); + FUNCTION_TEST_RETURN( + configOptionData[optionId].group ? configLocal->optionGroup[configOptionData[optionId].groupId].indexDefault : 0); +} + +/**********************************************************************************************************************************/ +unsigned int +cfgOptionIdxTotal(ConfigOption optionId) +{ + FUNCTION_TEST_BEGIN(); + FUNCTION_TEST_PARAM(ENUM, optionId); + FUNCTION_TEST_END(); + + ASSERT(configLocal != NULL); + ASSERT(optionId < CFG_OPTION_TOTAL); + + FUNCTION_TEST_RETURN( + configOptionData[optionId].group ? configLocal->optionGroup[configOptionData[optionId].groupId].indexTotal : 1); } /**********************************************************************************************************************************/ static Variant * -cfgOptionDefaultValue(ConfigDefineOption optionDefId) +cfgOptionDefaultValue(ConfigOption optionId) { FUNCTION_TEST_BEGIN(); - FUNCTION_TEST_PARAM(ENUM, optionDefId); + FUNCTION_TEST_PARAM(ENUM, optionId); FUNCTION_TEST_END(); Variant *result; - Variant *defaultValue = varNewStrZ(cfgDefOptionDefault(cfgCommand(), optionDefId)); + Variant *defaultValue = varNewStrZ(cfgDefOptionDefault(cfgCommand(), optionId)); - switch (cfgDefOptionType(optionDefId)) + switch (cfgDefOptionType(optionId)) { case cfgDefOptTypeBoolean: { @@ -564,7 +583,7 @@ cfgOptionDefaultValue(ConfigDefineOption optionDefId) break; default: - THROW_FMT(AssertError, "default value not available for option type %d", cfgDefOptionType(optionDefId)); + THROW_FMT(AssertError, "default value not available for option type %d", cfgDefOptionType(optionId)); } FUNCTION_TEST_RETURN(result); @@ -577,23 +596,22 @@ cfgOptionDefault(ConfigOption optionId) FUNCTION_TEST_PARAM(ENUM, optionId); FUNCTION_TEST_END(); + ASSERT(configLocal != NULL); ASSERT(optionId < CFG_OPTION_TOTAL); - if (configStatic.option[optionId].defaultValue == NULL) + if (configLocal->option[optionId].defaultValue == NULL) { - ConfigDefineOption optionDefId = cfgOptionDefIdFromId(optionId); - - if (cfgDefOptionDefault(cfgCommand(), optionDefId) != NULL) + if (cfgDefOptionDefault(cfgCommand(), optionId) != NULL) { - MEM_CONTEXT_BEGIN(configStatic.memContext) + MEM_CONTEXT_BEGIN(configLocal->memContext) { - configStatic.option[optionId].defaultValue = cfgOptionDefaultValue(optionDefId); + configLocal->option[optionId].defaultValue = cfgOptionDefaultValue(optionId); } MEM_CONTEXT_END(); } } - FUNCTION_TEST_RETURN(configStatic.option[optionId].defaultValue); + FUNCTION_TEST_RETURN(configLocal->option[optionId].defaultValue); } void @@ -605,20 +623,19 @@ cfgOptionDefaultSet(ConfigOption optionId, const Variant *defaultValue) FUNCTION_TEST_END(); ASSERT(optionId < CFG_OPTION_TOTAL); + ASSERT(configLocal != NULL); + ASSERT(configLocal->option[optionId].valid); - MEM_CONTEXT_BEGIN(configStatic.memContext) + MEM_CONTEXT_BEGIN(configLocal->memContext) { - if (configStatic.option[optionId].defaultValue != NULL) - varFree(configStatic.option[optionId].defaultValue); + // Set the default value + configLocal->option[optionId].defaultValue = varDup(defaultValue); - configStatic.option[optionId].defaultValue = varDup(defaultValue); - - if (configStatic.option[optionId].source == cfgSourceDefault) + // Copy the value to option indexes that are marked as default so the default can be retrieved quickly + for (unsigned int optionIdx = 0; optionIdx < cfgOptionIdxTotal(optionId); optionIdx++) { - if (configStatic.option[optionId].value != NULL) - varFree(configStatic.option[optionId].value); - - configStatic.option[optionId].value = varDup(defaultValue); + if (configLocal->option[optionId].index[optionIdx].source == cfgSourceDefault) + configLocal->option[optionId].index[optionIdx].value = configLocal->option[optionId].defaultValue; } } MEM_CONTEXT_END(); @@ -635,7 +652,23 @@ cfgOptionHostPort(ConfigOption optionId, unsigned int *port) FUNCTION_TEST_PARAM_P(UINT, port); FUNCTION_TEST_END(); + FUNCTION_TEST_RETURN(cfgOptionIdxHostPort(optionId, cfgOptionIdxDefault(optionId), port)); +} + +String * +cfgOptionIdxHostPort(ConfigOption optionId, unsigned int optionIdx, unsigned int *port) +{ + FUNCTION_TEST_BEGIN(); + FUNCTION_TEST_PARAM(ENUM, optionId); + FUNCTION_TEST_PARAM(UINT, optionIdx); + FUNCTION_TEST_PARAM_P(UINT, port); + FUNCTION_TEST_END(); + ASSERT(optionId < CFG_OPTION_TOTAL); + ASSERT(configLocal != NULL); + ASSERT( + (!configOptionData[optionId].group && optionIdx == 0) || + (configOptionData[optionId].group && optionIdx < configLocal->optionGroup[configOptionData[optionId].groupId].indexTotal)); ASSERT(port != NULL); String *result = NULL; @@ -645,7 +678,7 @@ cfgOptionHostPort(ConfigOption optionId, unsigned int *port) { MEM_CONTEXT_TEMP_BEGIN() { - const String *host = cfgOptionStr(optionId); + const String *host = cfgOptionIdxStr(optionId, optionIdx); // If the host contains a colon then it has a port appended if (strChr(host, ':') != -1) @@ -659,7 +692,7 @@ cfgOptionHostPort(ConfigOption optionId, unsigned int *port) OptionInvalidError, "'%s' is not valid for option '%s'" "\nHINT: is more than one port specified?", - strZ(host), cfgOptionName(optionId)); + strZ(host), cfgOptionIdxName(optionId, optionIdx)); } // Set the host @@ -680,7 +713,7 @@ cfgOptionHostPort(ConfigOption optionId, unsigned int *port) OptionInvalidError, "'%s' is not valid for option '%s'" "\nHINT: port is not a positive integer.", - strZ(host), cfgOptionName(optionId)); + strZ(host), cfgOptionIdxName(optionId, optionIdx)); } TRY_END(); } @@ -700,47 +733,6 @@ cfgOptionHostPort(ConfigOption optionId, unsigned int *port) FUNCTION_TEST_RETURN(result); } -/**********************************************************************************************************************************/ -unsigned int -cfgOptionIndex(ConfigOption optionId) -{ - FUNCTION_TEST_BEGIN(); - FUNCTION_TEST_PARAM(ENUM, optionId); - FUNCTION_TEST_END(); - - ASSERT(optionId < CFG_OPTION_TOTAL); - - FUNCTION_TEST_RETURN(configOptionData[optionId].index); -} - -/**********************************************************************************************************************************/ -ConfigOption -cfgOptionIdFromDefId(ConfigDefineOption optionDefId, unsigned int index) -{ - FUNCTION_TEST_BEGIN(); - FUNCTION_TEST_PARAM(ENUM, optionDefId); - FUNCTION_TEST_PARAM(UINT, index); - FUNCTION_TEST_END(); - - // Search for the option - ConfigOption optionId; - - for (optionId = 0; optionId < CFG_OPTION_TOTAL; optionId++) - { - if (configOptionData[optionId].defineId == optionDefId) - break; - } - - // If the mapping is not found then there is a bug in the code generator - ASSERT(optionId != CFG_OPTION_TOTAL); - - // Make sure the index is valid - ASSERT(index < cfgDefOptionIndexTotal(optionDefId)); - - // Return with original index - FUNCTION_TEST_RETURN(optionId + index); -} - /*********************************************************************************************************************************** Get option name by id ***********************************************************************************************************************************/ @@ -753,6 +745,56 @@ cfgOptionName(ConfigOption optionId) ASSERT(optionId < CFG_OPTION_TOTAL); + FUNCTION_TEST_RETURN(cfgOptionIdxName(optionId, cfgOptionIdxDefault(optionId))); +} + +const char * +cfgOptionKeyIdxName(ConfigOption optionId, unsigned int keyIdx) +{ + FUNCTION_TEST_BEGIN(); + FUNCTION_TEST_PARAM(ENUM, optionId); + FUNCTION_TEST_PARAM(UINT, keyIdx); + FUNCTION_TEST_END(); + + ASSERT(optionId < CFG_OPTION_TOTAL); + ASSERT((!configOptionData[optionId].group && keyIdx == 0) || configOptionData[optionId].group); + + // If the option is in a group then construct the name + if (configOptionData[optionId].group) + { + // This is somewhat less than ideal since memory is being allocated with each call, rather than caching prior results. In + // practice the number of allocations should be quite small so we'll ignore this for now. + String *name = strNewFmt( + "%s%u%s", configOptionGroupData[configOptionData[optionId].groupId].name, keyIdx + 1, + configOptionData[optionId].name + strlen(configOptionGroupData[configOptionData[optionId].groupId].name)); + + FUNCTION_TEST_RETURN(strZ(name)); + } + + // Else return the stored name + FUNCTION_TEST_RETURN(configOptionData[optionId].name); +} + +const char * +cfgOptionIdxName(ConfigOption optionId, unsigned int optionIdx) +{ + FUNCTION_TEST_BEGIN(); + FUNCTION_TEST_PARAM(ENUM, optionId); + FUNCTION_TEST_PARAM(UINT, optionIdx); + FUNCTION_TEST_END(); + + ASSERT(optionId < CFG_OPTION_TOTAL); + ASSERT(configLocal != NULL); + ASSERT( + (!configOptionData[optionId].group && optionIdx == 0) || + (configOptionData[optionId].group && optionIdx < configLocal->optionGroup[configOptionData[optionId].groupId].indexTotal)); + + if (configOptionData[optionId].group) + { + FUNCTION_TEST_RETURN( + cfgOptionKeyIdxName(optionId, configLocal->optionGroup[configOptionData[optionId].groupId].indexMap[optionIdx])); + } + FUNCTION_TEST_RETURN(configOptionData[optionId].name); } @@ -764,24 +806,24 @@ cfgOptionNegate(ConfigOption optionId) FUNCTION_TEST_PARAM(ENUM, optionId); FUNCTION_TEST_END(); - ASSERT(optionId < CFG_OPTION_TOTAL); - - FUNCTION_TEST_RETURN(configStatic.option[optionId].negate); + FUNCTION_TEST_RETURN(cfgOptionIdxNegate(optionId, cfgOptionIdxDefault(optionId))); } -void -cfgOptionNegateSet(ConfigOption optionId, bool negate) +bool +cfgOptionIdxNegate(ConfigOption optionId, unsigned int optionIdx) { FUNCTION_TEST_BEGIN(); FUNCTION_TEST_PARAM(ENUM, optionId); - FUNCTION_TEST_PARAM(BOOL, negate); + FUNCTION_TEST_PARAM(UINT, optionIdx); FUNCTION_TEST_END(); ASSERT(optionId < CFG_OPTION_TOTAL); + ASSERT(configLocal != NULL); + ASSERT( + (!configOptionData[optionId].group && optionIdx == 0) || + (configOptionData[optionId].group && optionIdx < configLocal->optionGroup[configOptionData[optionId].groupId].indexTotal)); - configStatic.option[optionId].negate = negate; - - FUNCTION_TEST_RETURN_VOID(); + FUNCTION_TEST_RETURN(configLocal->option[optionId].index[optionIdx].negate); } /**********************************************************************************************************************************/ @@ -792,58 +834,63 @@ cfgOptionReset(ConfigOption optionId) FUNCTION_TEST_PARAM(ENUM, optionId); FUNCTION_TEST_END(); - ASSERT(optionId < CFG_OPTION_TOTAL); - - FUNCTION_TEST_RETURN(configStatic.option[optionId].reset); + FUNCTION_TEST_RETURN(cfgOptionIdxReset(optionId, cfgOptionIdxDefault(optionId))); } -void -cfgOptionResetSet(ConfigOption optionId, bool reset) +bool +cfgOptionIdxReset(ConfigOption optionId, unsigned int optionIdx) { FUNCTION_TEST_BEGIN(); FUNCTION_TEST_PARAM(ENUM, optionId); - FUNCTION_TEST_PARAM(BOOL, reset); + FUNCTION_TEST_PARAM(UINT, optionIdx); FUNCTION_TEST_END(); ASSERT(optionId < CFG_OPTION_TOTAL); + ASSERT(configLocal != NULL); + ASSERT( + (!configOptionData[optionId].group && optionIdx == 0) || + (configOptionData[optionId].group && optionIdx < configLocal->optionGroup[configOptionData[optionId].groupId].indexTotal)); - configStatic.option[optionId].reset = reset; - - FUNCTION_TEST_RETURN_VOID(); + FUNCTION_TEST_RETURN(configLocal->option[optionId].index[optionIdx].reset); } /**********************************************************************************************************************************/ // Helper to enforce contraints when getting options -static Variant * -cfgOptionInternal(ConfigOption optionId, VariantType typeRequested, bool nullAllowed) +static const Variant * +cfgOptionIdxInternal(ConfigOption optionId, unsigned int optionIdx, VariantType typeRequested, bool nullAllowed) { FUNCTION_TEST_BEGIN(); FUNCTION_TEST_PARAM(ENUM, optionId); + FUNCTION_TEST_PARAM(UINT, optionIdx); FUNCTION_TEST_PARAM(ENUM, typeRequested); FUNCTION_TEST_PARAM(BOOL, nullAllowed); FUNCTION_TEST_END(); ASSERT(optionId < CFG_OPTION_TOTAL); + ASSERT(configLocal != NULL); + ASSERT( + (!configOptionData[optionId].group && optionIdx == 0) || + (configOptionData[optionId].group && optionIdx < configLocal->optionGroup[configOptionData[optionId].groupId].indexTotal)); // Check that the option is valid for the current command if (!cfgOptionValid(optionId)) - THROW_FMT(AssertError, "option '%s' is not valid for the current command", cfgOptionName(optionId)); + THROW_FMT(AssertError, "option '%s' is not valid for the current command", cfgOptionIdxName(optionId, optionIdx)); // If the option is not NULL then check it is the requested type - Variant *result = configStatic.option[optionId].value; + const Variant *result = configLocal->option[optionId].index[optionIdx].value; if (result != NULL) { if (varType(result) != typeRequested) { THROW_FMT( - AssertError, "option '%s' is type %u but %u was requested", cfgOptionName(optionId), varType(result), + AssertError, "option '%s' is type %u but %u was requested", cfgOptionIdxName(optionId, optionIdx), varType(result), typeRequested); } } // Else check the option is allowed to be NULL else if (!nullAllowed) - THROW_FMT(AssertError, "option '%s' is null but non-null was requested", cfgOptionName(optionId)); + THROW_FMT(AssertError, "option '%s' is null but non-null was requested", cfgOptionIdxName(optionId, optionIdx)); FUNCTION_TEST_RETURN(result); } @@ -855,9 +902,23 @@ cfgOption(ConfigOption optionId) FUNCTION_TEST_PARAM(ENUM, optionId); FUNCTION_TEST_END(); - ASSERT(optionId < CFG_OPTION_TOTAL); + FUNCTION_TEST_RETURN(cfgOptionIdx(optionId, cfgOptionIdxDefault(optionId))); +} - FUNCTION_TEST_RETURN(configStatic.option[optionId].value); +const Variant * +cfgOptionIdx(ConfigOption optionId, unsigned int optionIdx) +{ + FUNCTION_TEST_BEGIN(); + FUNCTION_TEST_PARAM(ENUM, optionId); + FUNCTION_TEST_PARAM(UINT, optionIdx); + FUNCTION_TEST_END(); + + ASSERT(configLocal != NULL); + ASSERT( + (!configOptionData[optionId].group && optionIdx == 0) || + (configOptionData[optionId].group && optionIdx < configLocal->optionGroup[configOptionData[optionId].groupId].indexTotal)); + + FUNCTION_TEST_RETURN(configLocal->option[optionId].index[optionIdx].value); } bool @@ -867,7 +928,18 @@ cfgOptionBool(ConfigOption optionId) FUNCTION_LOG_PARAM(ENUM, optionId); FUNCTION_LOG_END(); - FUNCTION_LOG_RETURN(BOOL, varBool(cfgOptionInternal(optionId, varTypeBool, false))); + FUNCTION_LOG_RETURN(BOOL, varBool(cfgOptionIdxInternal(optionId, cfgOptionIdxDefault(optionId), varTypeBool, false))); +} + +bool +cfgOptionIdxBool(ConfigOption optionId, unsigned int optionIdx) +{ + FUNCTION_LOG_BEGIN(logLevelTrace); + FUNCTION_LOG_PARAM(ENUM, optionId); + FUNCTION_LOG_PARAM(UINT, optionIdx); + FUNCTION_LOG_END(); + + FUNCTION_LOG_RETURN(BOOL, varBool(cfgOptionIdxInternal(optionId, optionIdx, varTypeBool, false))); } double @@ -877,7 +949,7 @@ cfgOptionDbl(ConfigOption optionId) FUNCTION_LOG_PARAM(ENUM, optionId); FUNCTION_LOG_END(); - FUNCTION_LOG_RETURN(DOUBLE, varDbl(cfgOptionInternal(optionId, varTypeDouble, false))); + FUNCTION_LOG_RETURN(DOUBLE, varDbl(cfgOptionIdxInternal(optionId, cfgOptionIdxDefault(optionId), varTypeDouble, false))); } int @@ -887,7 +959,18 @@ cfgOptionInt(ConfigOption optionId) FUNCTION_LOG_PARAM(ENUM, optionId); FUNCTION_LOG_END(); - FUNCTION_LOG_RETURN(INT, varIntForce(cfgOptionInternal(optionId, varTypeInt64, false))); + FUNCTION_LOG_RETURN(INT, varIntForce(cfgOptionIdxInternal(optionId, cfgOptionIdxDefault(optionId), varTypeInt64, false))); +} + +int +cfgOptionIdxInt(ConfigOption optionId, unsigned int optionIdx) +{ + FUNCTION_LOG_BEGIN(logLevelTrace); + FUNCTION_LOG_PARAM(ENUM, optionId); + FUNCTION_LOG_PARAM(UINT, optionIdx); + FUNCTION_LOG_END(); + + FUNCTION_LOG_RETURN(INT, varIntForce(cfgOptionIdxInternal(optionId, optionIdx, varTypeInt64, false))); } int64_t @@ -897,7 +980,18 @@ cfgOptionInt64(ConfigOption optionId) FUNCTION_LOG_PARAM(ENUM, optionId); FUNCTION_LOG_END(); - FUNCTION_LOG_RETURN(INT64, varInt64(cfgOptionInternal(optionId, varTypeInt64, false))); + FUNCTION_LOG_RETURN(INT64, varInt64(cfgOptionIdxInternal(optionId, cfgOptionIdxDefault(optionId), varTypeInt64, false))); +} + +int64_t +cfgOptionIdxInt64(ConfigOption optionId, unsigned int optionIdx) +{ + FUNCTION_LOG_BEGIN(logLevelTrace); + FUNCTION_LOG_PARAM(ENUM, optionId); + FUNCTION_LOG_PARAM(UINT, optionIdx); + FUNCTION_LOG_END(); + + FUNCTION_LOG_RETURN(INT64, varInt64(cfgOptionIdxInternal(optionId, optionIdx, varTypeInt64, false))); } unsigned int @@ -907,7 +1001,18 @@ cfgOptionUInt(ConfigOption optionId) FUNCTION_LOG_PARAM(ENUM, optionId); FUNCTION_LOG_END(); - FUNCTION_LOG_RETURN(UINT, varUIntForce(cfgOptionInternal(optionId, varTypeInt64, false))); + FUNCTION_LOG_RETURN(UINT, varUIntForce(cfgOptionIdxInternal(optionId, cfgOptionIdxDefault(optionId), varTypeInt64, false))); +} + +unsigned int +cfgOptionIdxUInt(ConfigOption optionId, unsigned int optionIdx) +{ + FUNCTION_LOG_BEGIN(logLevelTrace); + FUNCTION_LOG_PARAM(ENUM, optionId); + FUNCTION_LOG_PARAM(UINT, optionIdx); + FUNCTION_LOG_END(); + + FUNCTION_LOG_RETURN(UINT, varUIntForce(cfgOptionIdxInternal(optionId, optionIdx, varTypeInt64, false))); } uint64_t @@ -917,7 +1022,18 @@ cfgOptionUInt64(ConfigOption optionId) FUNCTION_LOG_PARAM(ENUM, optionId); FUNCTION_LOG_END(); - FUNCTION_LOG_RETURN(UINT64, varUInt64Force(cfgOptionInternal(optionId, varTypeInt64, false))); + FUNCTION_LOG_RETURN(UINT64, varUInt64Force(cfgOptionIdxInternal(optionId, cfgOptionIdxDefault(optionId), varTypeInt64, false))); +} + +uint64_t +cfgOptionIdxUInt64(ConfigOption optionId, unsigned int optionIdx) +{ + FUNCTION_LOG_BEGIN(logLevelTrace); + FUNCTION_LOG_PARAM(ENUM, optionId); + FUNCTION_LOG_PARAM(UINT, optionIdx); + FUNCTION_LOG_END(); + + FUNCTION_LOG_RETURN(UINT64, varUInt64Force(cfgOptionIdxInternal(optionId, optionIdx, varTypeInt64, false))); } const KeyValue * @@ -927,7 +1043,18 @@ cfgOptionKv(ConfigOption optionId) FUNCTION_LOG_PARAM(ENUM, optionId); FUNCTION_LOG_END(); - FUNCTION_LOG_RETURN(KEY_VALUE, varKv(cfgOptionInternal(optionId, varTypeKeyValue, false))); + FUNCTION_LOG_RETURN(KEY_VALUE, varKv(cfgOptionIdxInternal(optionId, cfgOptionIdxDefault(optionId), varTypeKeyValue, false))); +} + +const KeyValue * +cfgOptionIdxKv(ConfigOption optionId, unsigned int optionIdx) +{ + FUNCTION_LOG_BEGIN(logLevelTrace); + FUNCTION_LOG_PARAM(ENUM, optionId); + FUNCTION_LOG_PARAM(UINT, optionIdx); + FUNCTION_LOG_END(); + + FUNCTION_LOG_RETURN(KEY_VALUE, varKv(cfgOptionIdxInternal(optionId, optionIdx, varTypeKeyValue, false))); } const VariantList * @@ -937,14 +1064,27 @@ cfgOptionLst(ConfigOption optionId) FUNCTION_LOG_PARAM(ENUM, optionId); FUNCTION_LOG_END(); - Variant *optionValue = cfgOptionInternal(optionId, varTypeVariantList, true); + FUNCTION_LOG_RETURN_CONST(VARIANT_LIST, cfgOptionIdxLst(optionId, cfgOptionIdxDefault(optionId))); +} + +const VariantList * +cfgOptionIdxLst(ConfigOption optionId, unsigned int optionIdx) +{ + FUNCTION_LOG_BEGIN(logLevelTrace); + FUNCTION_LOG_PARAM(ENUM, optionId); + FUNCTION_LOG_PARAM(UINT, optionIdx); + FUNCTION_LOG_END(); + + ASSERT(configLocal != NULL); + + const Variant *optionValue = cfgOptionIdxInternal(optionId, optionIdx, varTypeVariantList, true); if (optionValue == NULL) { - MEM_CONTEXT_BEGIN(configStatic.memContext) + MEM_CONTEXT_BEGIN(configLocal->memContext) { optionValue = varNewVarLst(varLstNew()); - configStatic.option[optionId].value = optionValue; + configLocal->option[optionId].index[optionIdx].value = optionValue; } MEM_CONTEXT_END(); } @@ -959,7 +1099,18 @@ cfgOptionStr(ConfigOption optionId) FUNCTION_LOG_PARAM(ENUM, optionId); FUNCTION_LOG_END(); - FUNCTION_LOG_RETURN_CONST(STRING, varStr(cfgOptionInternal(optionId, varTypeString, false))); + FUNCTION_LOG_RETURN_CONST(STRING, varStr(cfgOptionIdxInternal(optionId, cfgOptionIdxDefault(optionId), varTypeString, false))); +} + +const String * +cfgOptionIdxStr(ConfigOption optionId, unsigned int optionIdx) +{ + FUNCTION_LOG_BEGIN(logLevelTrace); + FUNCTION_LOG_PARAM(ENUM, optionId); + FUNCTION_LOG_PARAM(UINT, optionIdx); + FUNCTION_LOG_END(); + + FUNCTION_LOG_RETURN_CONST(STRING, varStr(cfgOptionIdxInternal(optionId, optionIdx, varTypeString, false))); } const String * @@ -969,9 +1120,21 @@ cfgOptionStrNull(ConfigOption optionId) FUNCTION_LOG_PARAM(ENUM, optionId); FUNCTION_LOG_END(); - FUNCTION_LOG_RETURN_CONST(STRING, varStr(cfgOptionInternal(optionId, varTypeString, true))); + FUNCTION_LOG_RETURN_CONST(STRING, varStr(cfgOptionIdxInternal(optionId, cfgOptionIdxDefault(optionId), varTypeString, true))); } +const String * +cfgOptionIdxStrNull(ConfigOption optionId, unsigned int optionIdx) +{ + FUNCTION_LOG_BEGIN(logLevelTrace); + FUNCTION_LOG_PARAM(ENUM, optionId); + FUNCTION_LOG_PARAM(UINT, optionIdx); + FUNCTION_LOG_END(); + + FUNCTION_LOG_RETURN_CONST(STRING, varStr(cfgOptionIdxInternal(optionId, optionIdx, varTypeString, true))); +} + +/**********************************************************************************************************************************/ void cfgOptionSet(ConfigOption optionId, ConfigSource source, const Variant *value) { @@ -981,39 +1144,43 @@ cfgOptionSet(ConfigOption optionId, ConfigSource source, const Variant *value) FUNCTION_TEST_PARAM(VARIANT, value); FUNCTION_TEST_END(); - ASSERT(optionId < CFG_OPTION_TOTAL); + cfgOptionIdxSet(optionId, cfgOptionIdxDefault(optionId), source, value); - MEM_CONTEXT_BEGIN(configStatic.memContext) + FUNCTION_TEST_RETURN_VOID(); +} + +void +cfgOptionIdxSet(ConfigOption optionId, unsigned int optionIdx, ConfigSource source, const Variant *value) +{ + FUNCTION_TEST_BEGIN(); + FUNCTION_TEST_PARAM(ENUM, optionId); + FUNCTION_TEST_PARAM(UINT, optionIdx); + FUNCTION_TEST_PARAM(ENUM, source); + FUNCTION_TEST_PARAM(VARIANT, value); + FUNCTION_TEST_END(); + + ASSERT(optionId < CFG_OPTION_TOTAL); + ASSERT(configLocal != NULL); + ASSERT( + (!configOptionData[optionId].group && optionIdx == 0) || + (configOptionData[optionId].group && optionIdx < configLocal->optionGroup[configOptionData[optionId].groupId].indexTotal)); + + MEM_CONTEXT_BEGIN(configLocal->memContext) { // Set the source - configStatic.option[optionId].source = source; - - // Store old value - Variant *valueOld = configStatic.option[optionId].value; + configLocal->option[optionId].index[optionIdx].source = source; // Only set value if it is not null if (value != NULL) { - // If this option is in a group then set the value in the group for the option's index. This indicates that there is at - // least one option set in the group for that index. - if (configOptionData[optionId].group && source != cfgSourceDefault) - { - unsigned int groupId = configOptionData[optionId].groupId; - - configStatic.optionGroup[groupId].value |= (unsigned int)1 << configOptionData[optionId].index; - - if (configOptionData[optionId].index > configStatic.optionGroup[groupId].indexMax) - configStatic.optionGroup[groupId].indexMax = configOptionData[optionId].index; - } - - switch (cfgDefOptionType(cfgOptionDefIdFromId(optionId))) + switch (cfgDefOptionType(optionId)) { case cfgDefOptTypeBoolean: { if (varType(value) == varTypeBool) - configStatic.option[optionId].value = varDup(value); + configLocal->option[optionId].index[optionIdx].value = varDup(value); else - configStatic.option[optionId].value = varNewBool(varBoolForce(value)); + configLocal->option[optionId].index[optionIdx].value = varNewBool(varBoolForce(value)); break; } @@ -1021,9 +1188,9 @@ cfgOptionSet(ConfigOption optionId, ConfigSource source, const Variant *value) case cfgDefOptTypeFloat: { if (varType(value) == varTypeDouble) - configStatic.option[optionId].value = varDup(value); + configLocal->option[optionId].index[optionIdx].value = varDup(value); else - configStatic.option[optionId].value = varNewDbl(varDblForce(value)); + configLocal->option[optionId].index[optionIdx].value = varNewDbl(varDblForce(value)); break; } @@ -1032,29 +1199,9 @@ cfgOptionSet(ConfigOption optionId, ConfigSource source, const Variant *value) case cfgDefOptTypeSize: { if (varType(value) == varTypeInt64) - configStatic.option[optionId].value = varDup(value); + configLocal->option[optionId].index[optionIdx].value = varDup(value); else - configStatic.option[optionId].value = varNewInt64(varInt64Force(value)); - - break; - } - - case cfgDefOptTypeHash: - { - if (varType(value) == varTypeKeyValue) - configStatic.option[optionId].value = varDup(value); - else - THROW_FMT(AssertError, "option '%s' must be set with KeyValue variant", cfgOptionName(optionId)); - - break; - } - - case cfgDefOptTypeList: - { - if (varType(value) == varTypeVariantList) - configStatic.option[optionId].value = varDup(value); - else - THROW_FMT(AssertError, "option '%s' must be set with VariantList variant", cfgOptionName(optionId)); + configLocal->option[optionId].index[optionIdx].value = varNewInt64(varInt64Force(value)); break; } @@ -1063,20 +1210,22 @@ cfgOptionSet(ConfigOption optionId, ConfigSource source, const Variant *value) case cfgDefOptTypeString: { if (varType(value) == varTypeString) - configStatic.option[optionId].value = varDup(value); + configLocal->option[optionId].index[optionIdx].value = varDup(value); else - THROW_FMT(AssertError, "option '%s' must be set with String variant", cfgOptionName(optionId)); + { + THROW_FMT( + AssertError, "option '%s' must be set with String variant", cfgOptionIdxName(optionId, optionIdx)); + } break; } + + default: + THROW_FMT(AssertError, "set not available for option type %d", cfgDefOptionType(optionId)); } } else - configStatic.option[optionId].value = NULL; - - // Free old value - if (valueOld != NULL) - varFree(valueOld); + configLocal->option[optionId].index[optionIdx].value = NULL; } MEM_CONTEXT_END(); @@ -1091,9 +1240,24 @@ cfgOptionSource(ConfigOption optionId) FUNCTION_TEST_PARAM(ENUM, optionId); FUNCTION_TEST_END(); - ASSERT(optionId < CFG_OPTION_TOTAL); + FUNCTION_TEST_RETURN(cfgOptionIdxSource(optionId, cfgOptionIdxDefault(optionId))); +} - FUNCTION_TEST_RETURN(configStatic.option[optionId].source); +ConfigSource +cfgOptionIdxSource(ConfigOption optionId, unsigned int optionIdx) +{ + FUNCTION_TEST_BEGIN(); + FUNCTION_TEST_PARAM(ENUM, optionId); + FUNCTION_TEST_PARAM(UINT, optionIdx); + FUNCTION_TEST_END(); + + ASSERT(optionId < CFG_OPTION_TOTAL); + ASSERT(configLocal != NULL); + ASSERT( + (!configOptionData[optionId].group && optionIdx == 0) || + (configOptionData[optionId].group && optionIdx < configLocal->optionGroup[configOptionData[optionId].groupId].indexTotal)); + + FUNCTION_TEST_RETURN(configLocal->option[optionId].index[optionIdx].source); } /**********************************************************************************************************************************/ @@ -1104,9 +1268,24 @@ cfgOptionTest(ConfigOption optionId) FUNCTION_TEST_PARAM(ENUM, optionId); FUNCTION_TEST_END(); - ASSERT(optionId < CFG_OPTION_TOTAL); + FUNCTION_TEST_RETURN(cfgOptionIdxTest(optionId, cfgOptionIdxDefault(optionId))); +} - FUNCTION_TEST_RETURN(cfgOptionValid(optionId) && configStatic.option[optionId].value != NULL); +bool +cfgOptionIdxTest(ConfigOption optionId, unsigned int optionIdx) +{ + FUNCTION_TEST_BEGIN(); + FUNCTION_TEST_PARAM(ENUM, optionId); + FUNCTION_TEST_PARAM(UINT, optionIdx); + FUNCTION_TEST_END(); + + ASSERT(optionId < CFG_OPTION_TOTAL); + ASSERT(configLocal != NULL); + ASSERT( + (!configOptionData[optionId].group && optionIdx == 0) || + (configOptionData[optionId].group && optionIdx < configLocal->optionGroup[configOptionData[optionId].groupId].indexTotal)); + + FUNCTION_TEST_RETURN(cfgOptionValid(optionId) && configLocal->option[optionId].index[optionIdx].value != NULL); } /**********************************************************************************************************************************/ @@ -1118,25 +1297,22 @@ cfgOptionValid(ConfigOption optionId) FUNCTION_TEST_END(); ASSERT(optionId < CFG_OPTION_TOTAL); + ASSERT(configLocal != NULL); - FUNCTION_TEST_RETURN(configStatic.option[optionId].valid); + FUNCTION_TEST_RETURN(configLocal->option[optionId].valid); } void -cfgOptionValidSet(ConfigOption optionId, bool valid) +cfgOptionInvalidate(ConfigOption optionId) { FUNCTION_TEST_BEGIN(); FUNCTION_TEST_PARAM(ENUM, optionId); - FUNCTION_TEST_PARAM(BOOL, valid); FUNCTION_TEST_END(); ASSERT(optionId < CFG_OPTION_TOTAL); + ASSERT(configLocal != NULL); - configStatic.option[optionId].valid = valid; - - // If this option is in a group then the group is also valid - if (configOptionData[optionId].group) - configStatic.optionGroup[configOptionData[optionId].groupId].valid = true; + configLocal->option[optionId].valid = false; FUNCTION_TEST_RETURN_VOID(); } diff --git a/src/config/config.h b/src/config/config.h index 0662cb070..e3c1bffd9 100644 --- a/src/config/config.h +++ b/src/config/config.h @@ -12,7 +12,6 @@ config/parse.c sets the command and options and determines which options are val #include "common/type/stringList.h" #include "config/config.auto.h" -#include "config/define.auto.h" /*********************************************************************************************************************************** Command Role Enum @@ -88,20 +87,25 @@ bool cfgLogFile(void); // Default log level -- used for log messages that are common to all commands LogLevel cfgLogLevelDefault(void); -// Does this command allow parameters? -bool cfgParameterAllowed(void); - // Command parameters, if any const StringList *cfgCommandParam(void); +// Does this command allow parameters? +bool cfgCommandParameterAllowed(ConfigCommand commandId); + /*********************************************************************************************************************************** Option Group Functions ***********************************************************************************************************************************/ -// Are any options in the group with the specified index valid for the command and set by the user (i.e. not default)? -bool cfgOptionGroupIdxTest(ConfigOptionGroup groupId, unsigned int index); +// Get the default index for this group, i.e. the index that will be used if a non-indexed function like cfgOptionTest() is called. +unsigned int cfgOptionGroupIdxDefault(ConfigOptionGroup groupId); -// Total indexed groups, 0 if the group is not valid. Note that there may be gaps so each group index will need to be tested with -// cfgOptionGroupIdxTest() to make sure it contains data. +// Convert the group index to a key, i.e. the key that was used in the original configuration file, command-line, etc. Useful for +// messages that do not show an option name but must use an index that the user will recognize. It is preferrable to generate an +// option name with cfgOptionIdxName() when possible. +unsigned int cfgOptionGroupIdxToKey(ConfigOptionGroup groupId, unsigned int groupIdx); + +// Total indexes, 0 if the group is not valid. Will be the total configured indexes, no matter which raw indexes were used during +// configuration. e.g., if pg1-path and pg8-path are configured then this function will return 2. unsigned int cfgOptionGroupIdxTotal(ConfigOptionGroup groupId); // Are any options in the group valid for the command? @@ -110,32 +114,42 @@ bool cfgOptionGroupValid(ConfigOptionGroup groupId); /*********************************************************************************************************************************** Option Functions -Access option values, indexes, and determine if an option is valid for the current command. +Access option values, indexes, and determine if an option is valid for the current command. Most functions have a variant that +accepts an index, which currently work with non-indexed options (with optionIdx 0) but they may not always do so. ***********************************************************************************************************************************/ // Get config options for various types const Variant *cfgOption(ConfigOption optionId); +const Variant *cfgOptionIdx(ConfigOption optionId, unsigned int optionIdx); bool cfgOptionBool(ConfigOption optionId); +bool cfgOptionIdxBool(ConfigOption optionId, unsigned int optionIdx); double cfgOptionDbl(ConfigOption optionId); int cfgOptionInt(ConfigOption optionId); +int cfgOptionIdxInt(ConfigOption optionId, unsigned int optionIdx); int64_t cfgOptionInt64(ConfigOption optionId); +int64_t cfgOptionIdxInt64(ConfigOption optionId, unsigned int optionIdx); const KeyValue *cfgOptionKv(ConfigOption optionId); +const KeyValue *cfgOptionIdxKv(ConfigOption optionId, unsigned int optionIdx); const VariantList *cfgOptionLst(ConfigOption optionId); +const VariantList *cfgOptionIdxLst(ConfigOption optionId, unsigned int optionIdx); const String *cfgOptionStr(ConfigOption optionId); +const String *cfgOptionIdxStr(ConfigOption optionId, unsigned int optionIdx); const String *cfgOptionStrNull(ConfigOption optionId); +const String *cfgOptionIdxStrNull(ConfigOption optionId, unsigned int optionIdx); unsigned int cfgOptionUInt(ConfigOption optionId); +unsigned int cfgOptionIdxUInt(ConfigOption optionId, unsigned int optionIdx); uint64_t cfgOptionUInt64(ConfigOption optionId); - -// Get index for option -unsigned int cfgOptionIndex(ConfigOption optionId); +uint64_t cfgOptionIdxUInt64(ConfigOption optionId, unsigned int optionIdx); // Option name by id const char *cfgOptionName(ConfigOption optionId); +const char *cfgOptionIdxName(ConfigOption optionId, unsigned int optionIdx); // Is the option valid for this command? bool cfgOptionValid(ConfigOption optionId); -// Is the option valid for the command and set? +// Is the option valid for the command and also has a value? bool cfgOptionTest(ConfigOption optionId); +bool cfgOptionIdxTest(ConfigOption optionId, unsigned int optionIdx); /*********************************************************************************************************************************** Option Source Enum @@ -156,17 +170,12 @@ Load Functions Used primarily by modules that need to manipulate the configuration. These modules include, but are not limited to, config/parse.c, config/load.c. ***********************************************************************************************************************************/ -// Initialize or reinitialize the configuration data -void cfgInit(void); - // Was help requested? bool cfgCommandHelp(void); -void cfgCommandHelpSet(bool help); -// Get command id by name. If error is true then assert when the command does not exist. -ConfigCommand cfgCommandId(const char *commandName, bool error); +// Get command id by name +ConfigCommand cfgCommandId(const char *commandName); -void cfgCommandParamSet(const StringList *param); void cfgCommandSet(ConfigCommand commandId, ConfigCommandRole commandRoleId); // Get command/role name with custom separator @@ -178,39 +187,32 @@ const String *cfgCommandRoleStr(ConfigCommandRole commandRole); // pgBackRest exe const String *cfgExe(void); -void cfgExeSet(const String *exe); -// Option default +// Option default - should only be called by the help command const Variant *cfgOptionDefault(ConfigOption optionId); // Set option default. Option defaults are generally not set in advance because the vast majority of them are never used. It is // more efficient to generate them when they are requested. Some defaults are (e.g. the exe path) are set at runtime. void cfgOptionDefaultSet(ConfigOption optionId, const Variant *defaultValue); -// Get the option define for this option -ConfigDefineOption cfgOptionDefIdFromId(ConfigOption optionId); - // Parse a host option and extract the host and port (if it exists) String *cfgOptionHostPort(ConfigOption optionId, unsigned int *port); - -// Get the id for this option define -ConfigOption cfgOptionIdFromDefId(ConfigDefineOption optionDefId, unsigned int index); +String *cfgOptionIdxHostPort(ConfigOption optionId, unsigned int optionIdx, unsigned int *port); // Was the option negated? bool cfgOptionNegate(ConfigOption optionId); -void cfgOptionNegateSet(ConfigOption optionId, bool negate); +bool cfgOptionIdxNegate(ConfigOption optionId, unsigned int optionIdx); // Was the option reset? bool cfgOptionReset(ConfigOption optionId); -void cfgOptionResetSet(ConfigOption optionId, bool reset); +bool cfgOptionIdxReset(ConfigOption optionId, unsigned int optionIdx); // Set config option void cfgOptionSet(ConfigOption optionId, ConfigSource source, const Variant *value); +void cfgOptionIdxSet(ConfigOption optionId, unsigned int optionIdx, ConfigSource source, const Variant *value); // How was the option set (default, param, config)? ConfigSource cfgOptionSource(ConfigOption optionId); - -// Set option valid -void cfgOptionValidSet(ConfigOption optionId, bool valid); +ConfigSource cfgOptionIdxSource(ConfigOption optionId, unsigned int optionIdx); #endif diff --git a/src/config/config.intern.h b/src/config/config.intern.h new file mode 100644 index 000000000..212c71aaf --- /dev/null +++ b/src/config/config.intern.h @@ -0,0 +1,94 @@ +/*********************************************************************************************************************************** +Command and Option Configuration Internals + +These structures and functions are generally used by modules that create configurations, e.g. config/parse, or modules that +manipulate the configuration as a whole, e.g. protocol/helper, in order to communicate with other processes. + +The general-purpose functions for querying the current configuration are found in config.h. +***********************************************************************************************************************************/ +#ifndef CONFIG_CONFIG_INTERN_H +#define CONFIG_CONFIG_INTERN_H + +#include "config/config.h" + +/*********************************************************************************************************************************** +The maximum number of keys that an indexed option can have, e.g. pg256-path would be the maximum pg-path option +***********************************************************************************************************************************/ +#define CFG_OPTION_KEY_MAX 256 + +/*********************************************************************************************************************************** +Configuration data. These structures are not directly user-created or accessible. configParse() creates the structures and uses +cfgInit() to load it as the current configuration. Various cfg*() functions provide access. +***********************************************************************************************************************************/ +typedef struct ConfigOptionValue +{ + bool negate; // Is the option negated? + bool reset; // Is the option reset? + unsigned int source; // Where the option came from, i.e. ConfigSource enum + const Variant *value; // Value +} ConfigOptionValue; + +typedef struct Config +{ + MemContext *memContext; // Mem context for config data + + // Generally set by the command parser but can also be set by during execute to change commands, i.e. backup -> expire + ConfigCommand command; // Current command + ConfigCommandRole commandRole; // Current command role + + String *exe; // Location of the executable + bool help; // Was help requested for the command? + StringList *paramList; // Parameters passed to the command (if any) + + // Group options that are related together to allow valid and test checks across all options in the group + struct + { + bool valid; // Is option group valid for the current command? + unsigned int indexTotal; // Total number of indexes with values in option group + unsigned int indexDefault; // Default index (usually 0) + unsigned int indexMap[CFG_OPTION_KEY_MAX]; // List of index to key index mappings + } optionGroup[CFG_OPTION_GROUP_TOTAL]; + + // Option data + struct + { + bool valid; // Is option valid for current command? + const Variant *defaultValue; // Default value + ConfigOptionValue *index; // List of indexed values (only 1 unless the option is indexed) + } option[CFG_OPTION_TOTAL]; +} Config; + +/*********************************************************************************************************************************** +Init Function +***********************************************************************************************************************************/ +// Init with new configuration +void cfgInit(Config *config); + +/*********************************************************************************************************************************** +Option Group Functions +***********************************************************************************************************************************/ +// Is the option in a group? +bool cfgOptionGroup(ConfigOption optionId); + +// Group id if the option is in a group +unsigned int cfgOptionGroupId(ConfigOption optionId); + +/*********************************************************************************************************************************** +Option Functions +***********************************************************************************************************************************/ +// Get the option name using the key index -- i.e. the key that was used during configuration - 1, e.g. to get pg2-host pass 1 to +// keyIdx. +const char *cfgOptionKeyIdxName(ConfigOption optionId, unsigned int keyIdx); + +// Convert the key used in the original configuration to a group index. This is used when an option key must be translated into the +// local group index, e.g. during parsing or when getting the value of specific options from a remote. +unsigned int cfgOptionKeyToIdx(ConfigOption optionId, unsigned int key); + +// Total indexes for the option if in a group, 1 otherwise. +unsigned int cfgOptionIdxTotal(ConfigOption optionId); + +// Invalidate an option so it will not be passed to other processes. This is used to manage deprecated options that have a newer +// option that should be used when possible, e.g. compress and compress-type. +void cfgOptionInvalidate(ConfigOption optionId); + +#endif diff --git a/src/config/define.auto.c b/src/config/define.auto.c index e0b38704f..cd283226b 100644 --- a/src/config/define.auto.c +++ b/src/config/define.auto.c @@ -378,7 +378,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST ( - cfgDefOptOnline, + cfgOptOnline, "1" ) ) @@ -426,7 +426,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST ( - cfgDefOptArchiveCheck, + cfgOptArchiveCheck, "1" ) ) @@ -1403,7 +1403,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST ( - cfgDefOptOnline, + cfgOptOnline, "0" ) @@ -1477,33 +1477,6 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST ) ) - // ----------------------------------------------------------------------------------------------------------------------------- - CFGDEFDATA_OPTION - ( - CFGDEFDATA_OPTION_NAME("host-id") - CFGDEFDATA_OPTION_REQUIRED(false) - CFGDEFDATA_OPTION_SECTION(cfgDefSectionCommandLine) - CFGDEFDATA_OPTION_TYPE(cfgDefOptTypeInteger) - CFGDEFDATA_OPTION_INTERNAL(true) - - CFGDEFDATA_OPTION_INDEX_TOTAL(1) - CFGDEFDATA_OPTION_SECURE(false) - - CFGDEFDATA_OPTION_COMMAND_LIST - ( - CFGDEFDATA_OPTION_COMMAND(cfgCmdArchiveGet) - CFGDEFDATA_OPTION_COMMAND(cfgCmdArchivePush) - CFGDEFDATA_OPTION_COMMAND(cfgCmdBackup) - CFGDEFDATA_OPTION_COMMAND(cfgCmdRestore) - CFGDEFDATA_OPTION_COMMAND(cfgCmdVerify) - ) - - CFGDEFDATA_OPTION_OPTIONAL_LIST - ( - CFGDEFDATA_OPTION_OPTIONAL_ALLOW_RANGE(1, 8) - ) - ) - // ----------------------------------------------------------------------------------------------------------------------------- CFGDEFDATA_OPTION ( @@ -2246,6 +2219,63 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST ) ) + // ----------------------------------------------------------------------------------------------------------------------------- + CFGDEFDATA_OPTION + ( + CFGDEFDATA_OPTION_NAME("pg") + CFGDEFDATA_OPTION_REQUIRED(false) + CFGDEFDATA_OPTION_SECTION(cfgDefSectionStanza) + CFGDEFDATA_OPTION_TYPE(cfgDefOptTypeInteger) + CFGDEFDATA_OPTION_INTERNAL(true) + + CFGDEFDATA_OPTION_INDEX_TOTAL(1) + CFGDEFDATA_OPTION_SECURE(false) + + CFGDEFDATA_OPTION_COMMAND_LIST + ( + CFGDEFDATA_OPTION_COMMAND(cfgCmdArchiveGet) + CFGDEFDATA_OPTION_COMMAND(cfgCmdArchivePush) + CFGDEFDATA_OPTION_COMMAND(cfgCmdBackup) + CFGDEFDATA_OPTION_COMMAND(cfgCmdCheck) + CFGDEFDATA_OPTION_COMMAND(cfgCmdRestore) + CFGDEFDATA_OPTION_COMMAND(cfgCmdStanzaCreate) + CFGDEFDATA_OPTION_COMMAND(cfgCmdStanzaUpgrade) + ) + + CFGDEFDATA_OPTION_OPTIONAL_LIST + ( + CFGDEFDATA_OPTION_OPTIONAL_ALLOW_RANGE(1, 8) + + CFGDEFDATA_OPTION_OPTIONAL_COMMAND_OVERRIDE + ( + CFGDEFDATA_OPTION_OPTIONAL_COMMAND(cfgCmdBackup) + + CFGDEFDATA_OPTION_OPTIONAL_INTERNAL(true) + ) + + CFGDEFDATA_OPTION_OPTIONAL_COMMAND_OVERRIDE + ( + CFGDEFDATA_OPTION_OPTIONAL_COMMAND(cfgCmdCheck) + + CFGDEFDATA_OPTION_OPTIONAL_INTERNAL(true) + ) + + CFGDEFDATA_OPTION_OPTIONAL_COMMAND_OVERRIDE + ( + CFGDEFDATA_OPTION_OPTIONAL_COMMAND(cfgCmdStanzaCreate) + + CFGDEFDATA_OPTION_OPTIONAL_INTERNAL(true) + ) + + CFGDEFDATA_OPTION_OPTIONAL_COMMAND_OVERRIDE + ( + CFGDEFDATA_OPTION_OPTIONAL_COMMAND(cfgCmdStanzaUpgrade) + + CFGDEFDATA_OPTION_OPTIONAL_INTERNAL(true) + ) + ) + ) + // ----------------------------------------------------------------------------------------------------------------------------- CFGDEFDATA_OPTION ( @@ -2284,7 +2314,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST ( CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST ( - cfgDefOptPgLocal, + cfgOptPgLocal, "0" ) @@ -2347,7 +2377,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST CFGDEFDATA_OPTION_OPTIONAL_LIST ( - CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgDefOptPgHost) + CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgOptPgHost) CFGDEFDATA_OPTION_OPTIONAL_HELP_NAME_ALT("db-cmd") ) ) @@ -2386,7 +2416,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST CFGDEFDATA_OPTION_OPTIONAL_LIST ( - CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgDefOptPgHost) + CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgOptPgHost) CFGDEFDATA_OPTION_OPTIONAL_DEFAULT("/etc/pgbackrest/pgbackrest.conf") CFGDEFDATA_OPTION_OPTIONAL_HELP_NAME_ALT("db-config") ) @@ -2426,7 +2456,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST CFGDEFDATA_OPTION_OPTIONAL_LIST ( - CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgDefOptPgHost) + CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgOptPgHost) CFGDEFDATA_OPTION_OPTIONAL_DEFAULT("/etc/pgbackrest/conf.d") ) ) @@ -2465,7 +2495,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST CFGDEFDATA_OPTION_OPTIONAL_LIST ( - CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgDefOptPgHost) + CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgOptPgHost) CFGDEFDATA_OPTION_OPTIONAL_DEFAULT("/etc/pgbackrest") ) ) @@ -2504,7 +2534,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST CFGDEFDATA_OPTION_OPTIONAL_LIST ( CFGDEFDATA_OPTION_OPTIONAL_ALLOW_RANGE(0, 65535) - CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgDefOptPgHost) + CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgOptPgHost) CFGDEFDATA_OPTION_OPTIONAL_HELP_NAME_ALT("db-ssh-port") ) ) @@ -2543,7 +2573,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST CFGDEFDATA_OPTION_OPTIONAL_LIST ( - CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgDefOptPgHost) + CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgOptPgHost) CFGDEFDATA_OPTION_OPTIONAL_DEFAULT("postgres") CFGDEFDATA_OPTION_OPTIONAL_HELP_NAME_ALT("db-user") ) @@ -2684,7 +2714,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST CFGDEFDATA_OPTION_OPTIONAL_LIST ( CFGDEFDATA_OPTION_OPTIONAL_ALLOW_RANGE(0, 65535) - CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgDefOptPgPath) + CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgOptPgPath) CFGDEFDATA_OPTION_OPTIONAL_DEFAULT("5432") CFGDEFDATA_OPTION_OPTIONAL_HELP_NAME_ALT("db-port") ) @@ -2723,7 +2753,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST CFGDEFDATA_OPTION_OPTIONAL_LIST ( CFGDEFDATA_OPTION_OPTIONAL_ALLOW_RANGE(0, 65535) - CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgDefOptPgPath) + CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgOptPgPath) CFGDEFDATA_OPTION_OPTIONAL_HELP_NAME_ALT("db-socket-path") ) ) @@ -2759,7 +2789,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST CFGDEFDATA_OPTION_OPTIONAL_LIST ( - CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgDefOptPgPath) + CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgOptPgPath) ) ) @@ -2950,7 +2980,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST ( CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST ( - cfgDefOptType, + cfgOptType, "default", "immediate", "name", @@ -3048,6 +3078,46 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST ) ) + // ----------------------------------------------------------------------------------------------------------------------------- + CFGDEFDATA_OPTION + ( + CFGDEFDATA_OPTION_NAME("repo") + CFGDEFDATA_OPTION_REQUIRED(false) + CFGDEFDATA_OPTION_SECTION(cfgDefSectionGlobal) + CFGDEFDATA_OPTION_TYPE(cfgDefOptTypeInteger) + CFGDEFDATA_OPTION_INTERNAL(true) + + CFGDEFDATA_OPTION_INDEX_TOTAL(1) + CFGDEFDATA_OPTION_SECURE(false) + + CFGDEFDATA_OPTION_COMMAND_LIST + ( + CFGDEFDATA_OPTION_COMMAND(cfgCmdArchiveGet) + CFGDEFDATA_OPTION_COMMAND(cfgCmdArchivePush) + CFGDEFDATA_OPTION_COMMAND(cfgCmdBackup) + CFGDEFDATA_OPTION_COMMAND(cfgCmdCheck) + CFGDEFDATA_OPTION_COMMAND(cfgCmdExpire) + CFGDEFDATA_OPTION_COMMAND(cfgCmdInfo) + CFGDEFDATA_OPTION_COMMAND(cfgCmdRepoCreate) + CFGDEFDATA_OPTION_COMMAND(cfgCmdRepoGet) + CFGDEFDATA_OPTION_COMMAND(cfgCmdRepoLs) + CFGDEFDATA_OPTION_COMMAND(cfgCmdRepoPut) + CFGDEFDATA_OPTION_COMMAND(cfgCmdRepoRm) + CFGDEFDATA_OPTION_COMMAND(cfgCmdRestore) + CFGDEFDATA_OPTION_COMMAND(cfgCmdStanzaCreate) + CFGDEFDATA_OPTION_COMMAND(cfgCmdStanzaDelete) + CFGDEFDATA_OPTION_COMMAND(cfgCmdStanzaUpgrade) + CFGDEFDATA_OPTION_COMMAND(cfgCmdStart) + CFGDEFDATA_OPTION_COMMAND(cfgCmdStop) + CFGDEFDATA_OPTION_COMMAND(cfgCmdVerify) + ) + + CFGDEFDATA_OPTION_OPTIONAL_LIST + ( + CFGDEFDATA_OPTION_OPTIONAL_ALLOW_RANGE(1, 1) + ) + ) + // ----------------------------------------------------------------------------------------------------------------------------- CFGDEFDATA_OPTION ( @@ -3093,7 +3163,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST ( CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST ( - cfgDefOptRepoType, + cfgOptRepoType, "azure" ) ) @@ -3144,7 +3214,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST ( CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST ( - cfgDefOptRepoType, + cfgOptRepoType, "azure" ) ) @@ -3195,7 +3265,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST ( CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST ( - cfgDefOptRepoType, + cfgOptRepoType, "azure" ) ) @@ -3249,7 +3319,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST ( CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST ( - cfgDefOptRepoType, + cfgOptRepoType, "azure" ) ) @@ -3300,7 +3370,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST ( CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST ( - cfgDefOptRepoType, + cfgOptRepoType, "azure" ) @@ -3353,7 +3423,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST ( CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST ( - cfgDefOptRepoType, + cfgOptRepoType, "azure" ) ) @@ -3404,7 +3474,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST ( CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST ( - cfgDefOptRepoType, + cfgOptRepoType, "azure" ) ) @@ -3464,7 +3534,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST ( - cfgDefOptRepoType, + cfgOptRepoType, "azure" ) @@ -3518,7 +3588,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST CFGDEFDATA_OPTION_OPTIONAL_ALLOW_RANGE(1, 65535) CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST ( - cfgDefOptRepoType, + cfgOptRepoType, "azure" ) @@ -3572,7 +3642,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST ( CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST ( - cfgDefOptRepoType, + cfgOptRepoType, "azure" ) @@ -3625,7 +3695,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST ( CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST ( - cfgDefOptRepoCipherType, + cfgOptRepoCipherType, "aes-256-cbc" ) ) @@ -3769,7 +3839,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST ( CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST ( - cfgDefOptRepoLocal, + cfgOptRepoLocal, "0" ) @@ -3851,7 +3921,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST CFGDEFDATA_OPTION_OPTIONAL_LIST ( - CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgDefOptRepoHost) + CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgOptRepoHost) CFGDEFDATA_OPTION_OPTIONAL_HELP_NAME_ALT("backup-cmd") ) ) @@ -3895,7 +3965,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST CFGDEFDATA_OPTION_OPTIONAL_LIST ( - CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgDefOptRepoHost) + CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgOptRepoHost) CFGDEFDATA_OPTION_OPTIONAL_DEFAULT("/etc/pgbackrest/pgbackrest.conf") CFGDEFDATA_OPTION_OPTIONAL_HELP_NAME_ALT("backup-config") ) @@ -3940,7 +4010,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST CFGDEFDATA_OPTION_OPTIONAL_LIST ( - CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgDefOptRepoHost) + CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgOptRepoHost) CFGDEFDATA_OPTION_OPTIONAL_DEFAULT("/etc/pgbackrest/conf.d") ) ) @@ -3984,7 +4054,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST CFGDEFDATA_OPTION_OPTIONAL_LIST ( - CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgDefOptRepoHost) + CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgOptRepoHost) CFGDEFDATA_OPTION_OPTIONAL_DEFAULT("/etc/pgbackrest") ) ) @@ -4028,7 +4098,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST CFGDEFDATA_OPTION_OPTIONAL_LIST ( CFGDEFDATA_OPTION_OPTIONAL_ALLOW_RANGE(0, 65535) - CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgDefOptRepoHost) + CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgOptRepoHost) CFGDEFDATA_OPTION_OPTIONAL_HELP_NAME_ALT("backup-ssh-port") ) ) @@ -4074,7 +4144,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST CFGDEFDATA_OPTION_OPTIONAL_LIST ( - CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgDefOptRepoHost) + CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgOptRepoHost) CFGDEFDATA_OPTION_OPTIONAL_DEFAULT("pgbackrest") CFGDEFDATA_OPTION_OPTIONAL_HELP_NAME_ALT("backup-user") ) @@ -4455,7 +4525,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST ( CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST ( - cfgDefOptRepoType, + cfgOptRepoType, "s3" ) ) @@ -4506,7 +4576,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST ( CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST ( - cfgDefOptRepoType, + cfgOptRepoType, "s3" ) ) @@ -4557,7 +4627,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST ( CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST ( - cfgDefOptRepoType, + cfgOptRepoType, "s3" ) ) @@ -4608,7 +4678,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST ( CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST ( - cfgDefOptRepoType, + cfgOptRepoType, "s3" ) ) @@ -4659,7 +4729,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST ( CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST ( - cfgDefOptRepoType, + cfgOptRepoType, "s3" ) ) @@ -4710,7 +4780,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST ( CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST ( - cfgDefOptRepoS3KeyType, + cfgOptRepoS3KeyType, "shared" ) ) @@ -4761,7 +4831,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST ( CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST ( - cfgDefOptRepoS3KeyType, + cfgOptRepoS3KeyType, "shared" ) ) @@ -4821,7 +4891,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST ( - cfgDefOptRepoType, + cfgOptRepoType, "s3" ) @@ -4875,7 +4945,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST CFGDEFDATA_OPTION_OPTIONAL_ALLOW_RANGE(1, 65535) CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST ( - cfgDefOptRepoType, + cfgOptRepoType, "s3" ) @@ -4928,7 +4998,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST ( CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST ( - cfgDefOptRepoType, + cfgOptRepoType, "s3" ) ) @@ -4979,7 +5049,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST ( CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST ( - cfgDefOptRepoS3KeyType, + cfgOptRepoS3KeyType, "auto" ) ) @@ -5030,7 +5100,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST ( CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST ( - cfgDefOptRepoS3KeyType, + cfgOptRepoS3KeyType, "shared" ) ) @@ -5090,7 +5160,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST ( - cfgDefOptRepoType, + cfgOptRepoType, "s3" ) @@ -5144,7 +5214,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST ( CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST ( - cfgDefOptRepoType, + cfgOptRepoType, "s3" ) @@ -5374,7 +5444,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST ( CFGDEFDATA_OPTION_OPTIONAL_COMMAND(cfgCmdInfo) - CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgDefOptStanza) + CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgOptStanza) CFGDEFDATA_OPTION_OPTIONAL_REQUIRED(false) CFGDEFDATA_OPTION_OPTIONAL_HELP_SUMMARY("Backup set to detail.") @@ -5505,7 +5575,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST ( - cfgDefOptArchiveAsync, + cfgOptArchiveAsync, "1" ) ) @@ -5516,7 +5586,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST ( - cfgDefOptArchiveAsync, + cfgOptArchiveAsync, "1" ) ) @@ -5789,7 +5859,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST ( - cfgDefOptType, + cfgOptType, "name", "time", "xid" @@ -5836,7 +5906,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST ( - cfgDefOptType, + cfgOptType, "immediate", "name", "time", @@ -5886,7 +5956,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST ( - cfgDefOptType, + cfgOptType, "time", "xid" ) @@ -5930,7 +6000,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST ( - cfgDefOptType, + cfgOptType, "default", "name", "standby", @@ -5995,7 +6065,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST CFGDEFDATA_OPTION_OPTIONAL_ALLOW_RANGE(1, 32) CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST ( - cfgDefOptSckKeepAlive, + cfgOptSckKeepAlive, "1" ) ) @@ -6048,7 +6118,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST CFGDEFDATA_OPTION_OPTIONAL_ALLOW_RANGE(1, 3600) CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST ( - cfgDefOptSckKeepAlive, + cfgOptSckKeepAlive, "1" ) ) @@ -6101,7 +6171,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST CFGDEFDATA_OPTION_OPTIONAL_ALLOW_RANGE(1, 900) CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST ( - cfgDefOptSckKeepAlive, + cfgOptSckKeepAlive, "1" ) ) diff --git a/src/config/define.auto.h b/src/config/define.auto.h index 9bdee15e4..8f186eeb7 100644 --- a/src/config/define.auto.h +++ b/src/config/define.auto.h @@ -21,135 +21,4 @@ typedef enum cfgDefOptTypeString, } ConfigDefineOptionType; -/*********************************************************************************************************************************** -Option define enum -***********************************************************************************************************************************/ -typedef enum -{ - cfgDefOptArchiveAsync, - cfgDefOptArchiveCheck, - cfgDefOptArchiveCopy, - cfgDefOptArchiveGetQueueMax, - cfgDefOptArchiveMode, - cfgDefOptArchivePushQueueMax, - cfgDefOptArchiveTimeout, - cfgDefOptBackupStandby, - cfgDefOptBufferSize, - cfgDefOptChecksumPage, - cfgDefOptCipherPass, - cfgDefOptCmdSsh, - cfgDefOptCompress, - cfgDefOptCompressLevel, - cfgDefOptCompressLevelNetwork, - cfgDefOptCompressType, - cfgDefOptConfig, - cfgDefOptConfigIncludePath, - cfgDefOptConfigPath, - cfgDefOptDbInclude, - cfgDefOptDbTimeout, - cfgDefOptDelta, - cfgDefOptDryRun, - cfgDefOptExclude, - cfgDefOptExecId, - cfgDefOptExpireAuto, - cfgDefOptFilter, - cfgDefOptForce, - cfgDefOptHostId, - cfgDefOptIgnoreMissing, - cfgDefOptIoTimeout, - cfgDefOptLinkAll, - cfgDefOptLinkMap, - cfgDefOptLockPath, - cfgDefOptLogLevelConsole, - cfgDefOptLogLevelFile, - cfgDefOptLogLevelStderr, - cfgDefOptLogPath, - cfgDefOptLogSubprocess, - cfgDefOptLogTimestamp, - cfgDefOptManifestSaveThreshold, - cfgDefOptNeutralUmask, - cfgDefOptOnline, - cfgDefOptOutput, - cfgDefOptPgHost, - cfgDefOptPgHostCmd, - cfgDefOptPgHostConfig, - cfgDefOptPgHostConfigIncludePath, - cfgDefOptPgHostConfigPath, - cfgDefOptPgHostPort, - cfgDefOptPgHostUser, - cfgDefOptPgLocal, - cfgDefOptPgPath, - cfgDefOptPgPort, - cfgDefOptPgSocketPath, - cfgDefOptPgUser, - cfgDefOptProcess, - cfgDefOptProcessMax, - cfgDefOptProtocolTimeout, - cfgDefOptRaw, - cfgDefOptRecoveryOption, - cfgDefOptRecurse, - cfgDefOptRemoteType, - cfgDefOptRepoAzureAccount, - cfgDefOptRepoAzureCaFile, - cfgDefOptRepoAzureCaPath, - cfgDefOptRepoAzureContainer, - cfgDefOptRepoAzureEndpoint, - cfgDefOptRepoAzureHost, - cfgDefOptRepoAzureKey, - cfgDefOptRepoAzureKeyType, - cfgDefOptRepoAzurePort, - cfgDefOptRepoAzureVerifyTls, - cfgDefOptRepoCipherPass, - cfgDefOptRepoCipherType, - cfgDefOptRepoHardlink, - cfgDefOptRepoHost, - cfgDefOptRepoHostCmd, - cfgDefOptRepoHostConfig, - cfgDefOptRepoHostConfigIncludePath, - cfgDefOptRepoHostConfigPath, - cfgDefOptRepoHostPort, - cfgDefOptRepoHostUser, - cfgDefOptRepoLocal, - cfgDefOptRepoPath, - cfgDefOptRepoRetentionArchive, - cfgDefOptRepoRetentionArchiveType, - cfgDefOptRepoRetentionDiff, - cfgDefOptRepoRetentionFull, - cfgDefOptRepoRetentionFullType, - cfgDefOptRepoS3Bucket, - cfgDefOptRepoS3CaFile, - cfgDefOptRepoS3CaPath, - cfgDefOptRepoS3Endpoint, - cfgDefOptRepoS3Host, - cfgDefOptRepoS3Key, - cfgDefOptRepoS3KeySecret, - cfgDefOptRepoS3KeyType, - cfgDefOptRepoS3Port, - cfgDefOptRepoS3Region, - cfgDefOptRepoS3Role, - cfgDefOptRepoS3Token, - cfgDefOptRepoS3UriStyle, - cfgDefOptRepoS3VerifyTls, - cfgDefOptRepoType, - cfgDefOptResume, - cfgDefOptSckBlock, - cfgDefOptSckKeepAlive, - cfgDefOptSet, - cfgDefOptSort, - cfgDefOptSpoolPath, - cfgDefOptStanza, - cfgDefOptStartFast, - cfgDefOptStopAuto, - cfgDefOptTablespaceMap, - cfgDefOptTablespaceMapAll, - cfgDefOptTarget, - cfgDefOptTargetAction, - cfgDefOptTargetExclusive, - cfgDefOptTargetTimeline, - cfgDefOptTcpKeepAliveCount, - cfgDefOptTcpKeepAliveIdle, - cfgDefOptTcpKeepAliveInterval, - cfgDefOptType, -} ConfigDefineOption; - #endif diff --git a/src/config/define.c b/src/config/define.c index bc56ecf5b..42784bc6d 100644 --- a/src/config/define.c +++ b/src/config/define.c @@ -249,14 +249,14 @@ cfgDefDataFind( FUNCTION_TEST_RETURN_VOID(); } -#define CONFIG_DEFINE_DATA_FIND(commandId, optionDefId, type) \ +#define CONFIG_DEFINE_DATA_FIND(commandId, optionId, type) \ bool dataDefFound = false; \ int dataDef = 0; \ unsigned int dataDefListSize = 0; \ const void **dataDefList = NULL; \ \ cfgDefDataFind( \ - type, commandId, configDefineOptionData[optionDefId].data, &dataDefFound, &dataDef, &dataDefList, &dataDefListSize); + type, commandId, configDefineOptionData[optionId].data, &dataDefFound, &dataDef, &dataDefList, &dataDefListSize); /**********************************************************************************************************************************/ unsigned int @@ -300,74 +300,74 @@ cfgDefCommandHelpSummary(ConfigCommand commandId) /**********************************************************************************************************************************/ bool -cfgDefOptionAllowList(ConfigCommand commandId, ConfigDefineOption optionDefId) +cfgDefOptionAllowList(ConfigCommand commandId, ConfigOption optionId) { FUNCTION_TEST_BEGIN(); FUNCTION_TEST_PARAM(ENUM, commandId); - FUNCTION_TEST_PARAM(ENUM, optionDefId); + FUNCTION_TEST_PARAM(ENUM, optionId); FUNCTION_TEST_END(); ASSERT(commandId < cfgDefCommandTotal()); - ASSERT(optionDefId < cfgDefOptionTotal()); + ASSERT(optionId < cfgDefOptionTotal()); - CONFIG_DEFINE_DATA_FIND(commandId, optionDefId, configDefDataTypeAllowList); + CONFIG_DEFINE_DATA_FIND(commandId, optionId, configDefDataTypeAllowList); FUNCTION_TEST_RETURN(dataDefFound); } static unsigned int -cfgDefOptionAllowListValueTotal(ConfigCommand commandId, ConfigDefineOption optionDefId) +cfgDefOptionAllowListValueTotal(ConfigCommand commandId, ConfigOption optionId) { FUNCTION_TEST_BEGIN(); FUNCTION_TEST_PARAM(ENUM, commandId); - FUNCTION_TEST_PARAM(ENUM, optionDefId); + FUNCTION_TEST_PARAM(ENUM, optionId); FUNCTION_TEST_END(); ASSERT(commandId < cfgDefCommandTotal()); - ASSERT(optionDefId < cfgDefOptionTotal()); + ASSERT(optionId < cfgDefOptionTotal()); - CONFIG_DEFINE_DATA_FIND(commandId, optionDefId, configDefDataTypeAllowList); + CONFIG_DEFINE_DATA_FIND(commandId, optionId, configDefDataTypeAllowList); FUNCTION_TEST_RETURN(dataDefListSize); } static const char * -cfgDefOptionAllowListValue(ConfigCommand commandId, ConfigDefineOption optionDefId, unsigned int valueId) +cfgDefOptionAllowListValue(ConfigCommand commandId, ConfigOption optionId, unsigned int valueId) { FUNCTION_TEST_BEGIN(); FUNCTION_TEST_PARAM(ENUM, commandId); - FUNCTION_TEST_PARAM(ENUM, optionDefId); + FUNCTION_TEST_PARAM(ENUM, optionId); FUNCTION_TEST_PARAM(UINT, valueId); FUNCTION_TEST_END(); ASSERT(commandId < cfgDefCommandTotal()); - ASSERT(optionDefId < cfgDefOptionTotal()); - ASSERT(valueId < cfgDefOptionAllowListValueTotal(commandId, optionDefId)); + ASSERT(optionId < cfgDefOptionTotal()); + ASSERT(valueId < cfgDefOptionAllowListValueTotal(commandId, optionId)); - CONFIG_DEFINE_DATA_FIND(commandId, optionDefId, configDefDataTypeAllowList); + CONFIG_DEFINE_DATA_FIND(commandId, optionId, configDefDataTypeAllowList); FUNCTION_TEST_RETURN((char *)dataDefList[valueId]); } // Check if the value matches a value in the allow list bool -cfgDefOptionAllowListValueValid(ConfigCommand commandId, ConfigDefineOption optionDefId, const char *value) +cfgDefOptionAllowListValueValid(ConfigCommand commandId, ConfigOption optionId, const char *value) { FUNCTION_TEST_BEGIN(); FUNCTION_TEST_PARAM(ENUM, commandId); - FUNCTION_TEST_PARAM(ENUM, optionDefId); + FUNCTION_TEST_PARAM(ENUM, optionId); FUNCTION_TEST_PARAM(STRINGZ, value); FUNCTION_TEST_END(); ASSERT(commandId < cfgDefCommandTotal()); - ASSERT(optionDefId < cfgDefOptionTotal()); + ASSERT(optionId < cfgDefOptionTotal()); ASSERT(value != NULL); bool result = false; - for (unsigned int valueIdx = 0; valueIdx < cfgDefOptionAllowListValueTotal(commandId, optionDefId); valueIdx++) + for (unsigned int valueIdx = 0; valueIdx < cfgDefOptionAllowListValueTotal(commandId, optionId); valueIdx++) { - if (strcmp(value, cfgDefOptionAllowListValue(commandId, optionDefId, valueIdx)) == 0) + if (strcmp(value, cfgDefOptionAllowListValue(commandId, optionId, valueIdx)) == 0) result = true; } @@ -376,50 +376,50 @@ cfgDefOptionAllowListValueValid(ConfigCommand commandId, ConfigDefineOption opti /**********************************************************************************************************************************/ bool -cfgDefOptionAllowRange(ConfigCommand commandId, ConfigDefineOption optionDefId) +cfgDefOptionAllowRange(ConfigCommand commandId, ConfigOption optionId) { FUNCTION_TEST_BEGIN(); FUNCTION_TEST_PARAM(ENUM, commandId); - FUNCTION_TEST_PARAM(ENUM, optionDefId); + FUNCTION_TEST_PARAM(ENUM, optionId); FUNCTION_TEST_END(); ASSERT(commandId < cfgDefCommandTotal()); - ASSERT(optionDefId < cfgDefOptionTotal()); + ASSERT(optionId < cfgDefOptionTotal()); - CONFIG_DEFINE_DATA_FIND(commandId, optionDefId, configDefDataTypeAllowRange); + CONFIG_DEFINE_DATA_FIND(commandId, optionId, configDefDataTypeAllowRange); FUNCTION_TEST_RETURN(dataDefFound); } double -cfgDefOptionAllowRangeMax(ConfigCommand commandId, ConfigDefineOption optionDefId) +cfgDefOptionAllowRangeMax(ConfigCommand commandId, ConfigOption optionId) { FUNCTION_TEST_BEGIN(); FUNCTION_TEST_PARAM(ENUM, commandId); - FUNCTION_TEST_PARAM(ENUM, optionDefId); + FUNCTION_TEST_PARAM(ENUM, optionId); FUNCTION_TEST_END(); ASSERT(commandId < cfgDefCommandTotal()); - ASSERT(optionDefId < cfgDefOptionTotal()); + ASSERT(optionId < cfgDefOptionTotal()); - CONFIG_DEFINE_DATA_FIND(commandId, optionDefId, configDefDataTypeAllowRange); + CONFIG_DEFINE_DATA_FIND(commandId, optionId, configDefDataTypeAllowRange); FUNCTION_TEST_RETURN( ((double)(((int64_t)(intptr_t)dataDefList[2]) + (((int64_t)(intptr_t)dataDefList[3]) * 1000000000L))) / 100); } double -cfgDefOptionAllowRangeMin(ConfigCommand commandId, ConfigDefineOption optionDefId) +cfgDefOptionAllowRangeMin(ConfigCommand commandId, ConfigOption optionId) { FUNCTION_TEST_BEGIN(); FUNCTION_TEST_PARAM(ENUM, commandId); - FUNCTION_TEST_PARAM(ENUM, optionDefId); + FUNCTION_TEST_PARAM(ENUM, optionId); FUNCTION_TEST_END(); ASSERT(commandId < cfgDefCommandTotal()); - ASSERT(optionDefId < cfgDefOptionTotal()); + ASSERT(optionId < cfgDefOptionTotal()); - CONFIG_DEFINE_DATA_FIND(commandId, optionDefId, configDefDataTypeAllowRange); + CONFIG_DEFINE_DATA_FIND(commandId, optionId, configDefDataTypeAllowRange); FUNCTION_TEST_RETURN( ((double)(((int64_t)(intptr_t)dataDefList[0]) + (((int64_t)(intptr_t)dataDefList[1]) * 1000000000L))) / 100); @@ -427,17 +427,17 @@ cfgDefOptionAllowRangeMin(ConfigCommand commandId, ConfigDefineOption optionDefI /**********************************************************************************************************************************/ const char * -cfgDefOptionDefault(ConfigCommand commandId, ConfigDefineOption optionDefId) +cfgDefOptionDefault(ConfigCommand commandId, ConfigOption optionId) { FUNCTION_TEST_BEGIN(); FUNCTION_TEST_PARAM(ENUM, commandId); - FUNCTION_TEST_PARAM(ENUM, optionDefId); + FUNCTION_TEST_PARAM(ENUM, optionId); FUNCTION_TEST_END(); ASSERT(commandId < cfgDefCommandTotal()); - ASSERT(optionDefId < cfgDefOptionTotal()); + ASSERT(optionId < cfgDefOptionTotal()); - CONFIG_DEFINE_DATA_FIND(commandId, optionDefId, configDefDataTypeDefault); + CONFIG_DEFINE_DATA_FIND(commandId, optionId, configDefDataTypeDefault); char *result = NULL; @@ -449,90 +449,90 @@ cfgDefOptionDefault(ConfigCommand commandId, ConfigDefineOption optionDefId) /**********************************************************************************************************************************/ bool -cfgDefOptionDepend(ConfigCommand commandId, ConfigDefineOption optionDefId) +cfgDefOptionDepend(ConfigCommand commandId, ConfigOption optionId) { FUNCTION_TEST_BEGIN(); FUNCTION_TEST_PARAM(ENUM, commandId); - FUNCTION_TEST_PARAM(ENUM, optionDefId); + FUNCTION_TEST_PARAM(ENUM, optionId); FUNCTION_TEST_END(); ASSERT(commandId < cfgDefCommandTotal()); - ASSERT(optionDefId < cfgDefOptionTotal()); + ASSERT(optionId < cfgDefOptionTotal()); - CONFIG_DEFINE_DATA_FIND(commandId, optionDefId, configDefDataTypeDepend); + CONFIG_DEFINE_DATA_FIND(commandId, optionId, configDefDataTypeDepend); FUNCTION_TEST_RETURN(dataDefFound); } -ConfigDefineOption -cfgDefOptionDependOption(ConfigCommand commandId, ConfigDefineOption optionDefId) +ConfigOption +cfgDefOptionDependOption(ConfigCommand commandId, ConfigOption optionId) { FUNCTION_TEST_BEGIN(); FUNCTION_TEST_PARAM(ENUM, commandId); - FUNCTION_TEST_PARAM(ENUM, optionDefId); + FUNCTION_TEST_PARAM(ENUM, optionId); FUNCTION_TEST_END(); ASSERT(commandId < cfgDefCommandTotal()); - ASSERT(optionDefId < cfgDefOptionTotal()); + ASSERT(optionId < cfgDefOptionTotal()); - CONFIG_DEFINE_DATA_FIND(commandId, optionDefId, configDefDataTypeDepend); + CONFIG_DEFINE_DATA_FIND(commandId, optionId, configDefDataTypeDepend); - FUNCTION_TEST_RETURN((ConfigDefineOption)dataDef); + FUNCTION_TEST_RETURN((ConfigOption)dataDef); } const char * -cfgDefOptionDependValue(ConfigCommand commandId, ConfigDefineOption optionDefId, unsigned int valueId) +cfgDefOptionDependValue(ConfigCommand commandId, ConfigOption optionId, unsigned int valueId) { FUNCTION_TEST_BEGIN(); FUNCTION_TEST_PARAM(ENUM, commandId); - FUNCTION_TEST_PARAM(ENUM, optionDefId); + FUNCTION_TEST_PARAM(ENUM, optionId); FUNCTION_TEST_PARAM(UINT, valueId); FUNCTION_TEST_END(); ASSERT(commandId < cfgDefCommandTotal()); - ASSERT(optionDefId < cfgDefOptionTotal()); - ASSERT(valueId < cfgDefOptionDependValueTotal(commandId, optionDefId)); + ASSERT(optionId < cfgDefOptionTotal()); + ASSERT(valueId < cfgDefOptionDependValueTotal(commandId, optionId)); - CONFIG_DEFINE_DATA_FIND(commandId, optionDefId, configDefDataTypeDepend); + CONFIG_DEFINE_DATA_FIND(commandId, optionId, configDefDataTypeDepend); FUNCTION_TEST_RETURN((char *)dataDefList[valueId]); } unsigned int -cfgDefOptionDependValueTotal(ConfigCommand commandId, ConfigDefineOption optionDefId) +cfgDefOptionDependValueTotal(ConfigCommand commandId, ConfigOption optionId) { FUNCTION_TEST_BEGIN(); FUNCTION_TEST_PARAM(ENUM, commandId); - FUNCTION_TEST_PARAM(ENUM, optionDefId); + FUNCTION_TEST_PARAM(ENUM, optionId); FUNCTION_TEST_END(); ASSERT(commandId < cfgDefCommandTotal()); - ASSERT(optionDefId < cfgDefOptionTotal()); + ASSERT(optionId < cfgDefOptionTotal()); - CONFIG_DEFINE_DATA_FIND(commandId, optionDefId, configDefDataTypeDepend); + CONFIG_DEFINE_DATA_FIND(commandId, optionId, configDefDataTypeDepend); FUNCTION_TEST_RETURN(dataDefListSize); } // Check if the value matches a value in the allow list bool -cfgDefOptionDependValueValid(ConfigCommand commandId, ConfigDefineOption optionDefId, const char *value) +cfgDefOptionDependValueValid(ConfigCommand commandId, ConfigOption optionId, const char *value) { FUNCTION_TEST_BEGIN(); FUNCTION_TEST_PARAM(ENUM, commandId); - FUNCTION_TEST_PARAM(ENUM, optionDefId); + FUNCTION_TEST_PARAM(ENUM, optionId); FUNCTION_TEST_PARAM(STRINGZ, value); FUNCTION_TEST_END(); ASSERT(commandId < cfgDefCommandTotal()); - ASSERT(optionDefId < cfgDefOptionTotal()); + ASSERT(optionId < cfgDefOptionTotal()); ASSERT(value != NULL); bool result = false; - for (unsigned int valueIdx = 0; valueIdx < cfgDefOptionDependValueTotal(commandId, optionDefId); valueIdx++) + for (unsigned int valueIdx = 0; valueIdx < cfgDefOptionDependValueTotal(commandId, optionId); valueIdx++) { - if (strcmp(value, cfgDefOptionDependValue(commandId, optionDefId, valueIdx)) == 0) + if (strcmp(value, cfgDefOptionDependValue(commandId, optionId, valueIdx)) == 0) result = true; } @@ -541,19 +541,19 @@ cfgDefOptionDependValueValid(ConfigCommand commandId, ConfigDefineOption optionD /**********************************************************************************************************************************/ const char * -cfgDefOptionHelpDescription(ConfigCommand commandId, ConfigDefineOption optionDefId) +cfgDefOptionHelpDescription(ConfigCommand commandId, ConfigOption optionId) { FUNCTION_TEST_BEGIN(); FUNCTION_TEST_PARAM(ENUM, commandId); - FUNCTION_TEST_PARAM(ENUM, optionDefId); + FUNCTION_TEST_PARAM(ENUM, optionId); FUNCTION_TEST_END(); ASSERT(commandId < cfgDefCommandTotal()); - ASSERT(optionDefId < cfgDefOptionTotal()); + ASSERT(optionId < cfgDefOptionTotal()); - CONFIG_DEFINE_DATA_FIND(commandId, optionDefId, configDefDataTypeHelpDescription); + CONFIG_DEFINE_DATA_FIND(commandId, optionId, configDefDataTypeHelpDescription); - const char *result = configDefineOptionData[optionDefId].helpDescription; + const char *result = configDefineOptionData[optionId].helpDescription; if (dataDefFound) result = (char *)dataDefList[0]; @@ -563,77 +563,77 @@ cfgDefOptionHelpDescription(ConfigCommand commandId, ConfigDefineOption optionDe /**********************************************************************************************************************************/ bool -cfgDefOptionHelpNameAlt(ConfigDefineOption optionDefId) +cfgDefOptionHelpNameAlt(ConfigOption optionId) { FUNCTION_TEST_BEGIN(); - FUNCTION_TEST_PARAM(ENUM, optionDefId); + FUNCTION_TEST_PARAM(ENUM, optionId); FUNCTION_TEST_END(); - ASSERT(optionDefId < cfgDefOptionTotal()); + ASSERT(optionId < cfgDefOptionTotal()); - CONFIG_DEFINE_DATA_FIND(-1, optionDefId, configDefDataTypeHelpNameAlt); + CONFIG_DEFINE_DATA_FIND(-1, optionId, configDefDataTypeHelpNameAlt); FUNCTION_TEST_RETURN(dataDefFound); } const char * -cfgDefOptionHelpNameAltValue(ConfigDefineOption optionDefId, unsigned int valueId) +cfgDefOptionHelpNameAltValue(ConfigOption optionId, unsigned int valueId) { FUNCTION_TEST_BEGIN(); - FUNCTION_TEST_PARAM(ENUM, optionDefId); + FUNCTION_TEST_PARAM(ENUM, optionId); FUNCTION_TEST_PARAM(UINT, valueId); FUNCTION_TEST_END(); - ASSERT(optionDefId < cfgDefOptionTotal()); - ASSERT(valueId < cfgDefOptionHelpNameAltValueTotal(optionDefId)); + ASSERT(optionId < cfgDefOptionTotal()); + ASSERT(valueId < cfgDefOptionHelpNameAltValueTotal(optionId)); - CONFIG_DEFINE_DATA_FIND(-1, optionDefId, configDefDataTypeHelpNameAlt); + CONFIG_DEFINE_DATA_FIND(-1, optionId, configDefDataTypeHelpNameAlt); FUNCTION_TEST_RETURN((char *)dataDefList[valueId]); } unsigned int -cfgDefOptionHelpNameAltValueTotal(ConfigDefineOption optionDefId) +cfgDefOptionHelpNameAltValueTotal(ConfigOption optionId) { FUNCTION_TEST_BEGIN(); - FUNCTION_TEST_PARAM(ENUM, optionDefId); + FUNCTION_TEST_PARAM(ENUM, optionId); FUNCTION_TEST_END(); - ASSERT(optionDefId < cfgDefOptionTotal()); + ASSERT(optionId < cfgDefOptionTotal()); - CONFIG_DEFINE_DATA_FIND(-1, optionDefId, configDefDataTypeHelpNameAlt); + CONFIG_DEFINE_DATA_FIND(-1, optionId, configDefDataTypeHelpNameAlt); FUNCTION_TEST_RETURN(dataDefListSize); } /**********************************************************************************************************************************/ const char * -cfgDefOptionHelpSection(ConfigDefineOption optionDefId) +cfgDefOptionHelpSection(ConfigOption optionId) { FUNCTION_TEST_BEGIN(); - FUNCTION_TEST_PARAM(ENUM, optionDefId); + FUNCTION_TEST_PARAM(ENUM, optionId); FUNCTION_TEST_END(); - ASSERT(optionDefId < cfgDefOptionTotal()); + ASSERT(optionId < cfgDefOptionTotal()); - FUNCTION_TEST_RETURN(configDefineOptionData[optionDefId].helpSection); + FUNCTION_TEST_RETURN(configDefineOptionData[optionId].helpSection); } /**********************************************************************************************************************************/ const char * -cfgDefOptionHelpSummary(ConfigCommand commandId, ConfigDefineOption optionDefId) +cfgDefOptionHelpSummary(ConfigCommand commandId, ConfigOption optionId) { FUNCTION_TEST_BEGIN(); FUNCTION_TEST_PARAM(ENUM, commandId); - FUNCTION_TEST_PARAM(ENUM, optionDefId); + FUNCTION_TEST_PARAM(ENUM, optionId); FUNCTION_TEST_END(); ASSERT(commandId < cfgDefCommandTotal()); - ASSERT(optionDefId < cfgDefOptionTotal()); + ASSERT(optionId < cfgDefOptionTotal()); - CONFIG_DEFINE_DATA_FIND(commandId, optionDefId, configDefDataTypeHelpSummary); + CONFIG_DEFINE_DATA_FIND(commandId, optionId, configDefDataTypeHelpSummary); - const char *result = configDefineOptionData[optionDefId].helpSummary; + const char *result = configDefineOptionData[optionId].helpSummary; if (dataDefFound) result = (char *)dataDefList[0]; @@ -653,41 +653,41 @@ cfgDefOptionId(const char *optionName) int result = -1; - for (ConfigDefineOption optionDefId = 0; optionDefId < cfgDefOptionTotal(); optionDefId++) - if (strcmp(optionName, configDefineOptionData[optionDefId].name) == 0) - result = optionDefId; + for (ConfigOption optionId = 0; optionId < cfgDefOptionTotal(); optionId++) + if (strcmp(optionName, configDefineOptionData[optionId].name) == 0) + result = optionId; FUNCTION_TEST_RETURN(result); } /**********************************************************************************************************************************/ unsigned int -cfgDefOptionIndexTotal(ConfigDefineOption optionDefId) +cfgDefOptionIndexTotal(ConfigOption optionId) { FUNCTION_TEST_BEGIN(); - FUNCTION_TEST_PARAM(ENUM, optionDefId); + FUNCTION_TEST_PARAM(ENUM, optionId); FUNCTION_TEST_END(); - ASSERT(optionDefId < cfgDefOptionTotal()); + ASSERT(optionId < cfgDefOptionTotal()); - FUNCTION_TEST_RETURN(configDefineOptionData[optionDefId].indexTotal); + FUNCTION_TEST_RETURN(configDefineOptionData[optionId].indexTotal); } /**********************************************************************************************************************************/ bool -cfgDefOptionInternal(ConfigCommand commandId, ConfigDefineOption optionDefId) +cfgDefOptionInternal(ConfigCommand commandId, ConfigOption optionId) { FUNCTION_TEST_BEGIN(); FUNCTION_TEST_PARAM(ENUM, commandId); - FUNCTION_TEST_PARAM(ENUM, optionDefId); + FUNCTION_TEST_PARAM(ENUM, optionId); FUNCTION_TEST_END(); ASSERT(commandId < cfgDefCommandTotal()); - ASSERT(optionDefId < cfgDefOptionTotal()); + ASSERT(optionId < cfgDefOptionTotal()); - CONFIG_DEFINE_DATA_FIND(commandId, optionDefId, configDefDataTypeInternal); + CONFIG_DEFINE_DATA_FIND(commandId, optionId, configDefDataTypeInternal); - bool result = configDefineOptionData[optionDefId].internal; + bool result = configDefineOptionData[optionId].internal; if (dataDefFound) result = (bool)dataDef; @@ -697,60 +697,60 @@ cfgDefOptionInternal(ConfigCommand commandId, ConfigDefineOption optionDefId) /**********************************************************************************************************************************/ bool -cfgDefOptionMulti(ConfigDefineOption optionDefId) +cfgDefOptionMulti(ConfigOption optionId) { FUNCTION_TEST_BEGIN(); - FUNCTION_TEST_PARAM(ENUM, optionDefId); + FUNCTION_TEST_PARAM(ENUM, optionId); FUNCTION_TEST_END(); - ASSERT(optionDefId < cfgDefOptionTotal()); + ASSERT(optionId < cfgDefOptionTotal()); FUNCTION_TEST_RETURN( - configDefineOptionData[optionDefId].type == cfgDefOptTypeHash || - configDefineOptionData[optionDefId].type == cfgDefOptTypeList); + configDefineOptionData[optionId].type == cfgDefOptTypeHash || + configDefineOptionData[optionId].type == cfgDefOptTypeList); } /**********************************************************************************************************************************/ const char * -cfgDefOptionName(ConfigDefineOption optionDefId) +cfgDefOptionName(ConfigOption optionId) { FUNCTION_TEST_BEGIN(); - FUNCTION_TEST_PARAM(ENUM, optionDefId); + FUNCTION_TEST_PARAM(ENUM, optionId); FUNCTION_TEST_END(); - ASSERT(optionDefId < cfgDefOptionTotal()); + ASSERT(optionId < cfgDefOptionTotal()); - FUNCTION_TEST_RETURN(configDefineOptionData[optionDefId].name); + FUNCTION_TEST_RETURN(configDefineOptionData[optionId].name); } /**********************************************************************************************************************************/ bool -cfgDefOptionSecure(ConfigDefineOption optionDefId) +cfgDefOptionSecure(ConfigOption optionId) { FUNCTION_TEST_BEGIN(); - FUNCTION_TEST_PARAM(ENUM, optionDefId); + FUNCTION_TEST_PARAM(ENUM, optionId); FUNCTION_TEST_END(); - ASSERT(optionDefId < cfgDefOptionTotal()); + ASSERT(optionId < cfgDefOptionTotal()); - FUNCTION_TEST_RETURN(configDefineOptionData[optionDefId].secure); + FUNCTION_TEST_RETURN(configDefineOptionData[optionId].secure); } /**********************************************************************************************************************************/ bool -cfgDefOptionRequired(ConfigCommand commandId, ConfigDefineOption optionDefId) +cfgDefOptionRequired(ConfigCommand commandId, ConfigOption optionId) { FUNCTION_TEST_BEGIN(); FUNCTION_TEST_PARAM(ENUM, commandId); - FUNCTION_TEST_PARAM(ENUM, optionDefId); + FUNCTION_TEST_PARAM(ENUM, optionId); FUNCTION_TEST_END(); ASSERT(commandId < cfgDefCommandTotal()); - ASSERT(optionDefId < cfgDefOptionTotal()); + ASSERT(optionId < cfgDefOptionTotal()); - CONFIG_DEFINE_DATA_FIND(commandId, optionDefId, configDefDataTypeRequired); + CONFIG_DEFINE_DATA_FIND(commandId, optionId, configDefDataTypeRequired); - bool result = configDefineOptionData[optionDefId].required; + bool result = configDefineOptionData[optionId].required; if (dataDefFound) result = (bool)dataDef; @@ -760,41 +760,41 @@ cfgDefOptionRequired(ConfigCommand commandId, ConfigDefineOption optionDefId) /**********************************************************************************************************************************/ ConfigDefSection -cfgDefOptionSection(ConfigDefineOption optionDefId) +cfgDefOptionSection(ConfigOption optionId) { FUNCTION_TEST_BEGIN(); - FUNCTION_TEST_PARAM(ENUM, optionDefId); + FUNCTION_TEST_PARAM(ENUM, optionId); FUNCTION_TEST_END(); - ASSERT(optionDefId < cfgDefOptionTotal()); + ASSERT(optionId < cfgDefOptionTotal()); - FUNCTION_TEST_RETURN(configDefineOptionData[optionDefId].section); + FUNCTION_TEST_RETURN(configDefineOptionData[optionId].section); } /**********************************************************************************************************************************/ int -cfgDefOptionType(ConfigDefineOption optionDefId) +cfgDefOptionType(ConfigOption optionId) { FUNCTION_TEST_BEGIN(); - FUNCTION_TEST_PARAM(ENUM, optionDefId); + FUNCTION_TEST_PARAM(ENUM, optionId); FUNCTION_TEST_END(); - ASSERT(optionDefId < cfgDefOptionTotal()); + ASSERT(optionId < cfgDefOptionTotal()); - FUNCTION_TEST_RETURN(configDefineOptionData[optionDefId].type); + FUNCTION_TEST_RETURN(configDefineOptionData[optionId].type); } /**********************************************************************************************************************************/ bool -cfgDefOptionValid(ConfigCommand commandId, ConfigDefineOption optionDefId) +cfgDefOptionValid(ConfigCommand commandId, ConfigOption optionId) { FUNCTION_TEST_BEGIN(); FUNCTION_TEST_PARAM(ENUM, commandId); - FUNCTION_TEST_PARAM(ENUM, optionDefId); + FUNCTION_TEST_PARAM(ENUM, optionId); FUNCTION_TEST_END(); ASSERT(commandId < cfgDefCommandTotal()); - ASSERT(optionDefId < cfgDefOptionTotal()); + ASSERT(optionId < cfgDefOptionTotal()); - FUNCTION_TEST_RETURN(configDefineOptionData[optionDefId].commandValid & (1 << commandId)); + FUNCTION_TEST_RETURN(configDefineOptionData[optionId].commandValid & (1 << commandId)); } diff --git a/src/config/define.h b/src/config/define.h index 6f8bafc59..9b1d800b0 100644 --- a/src/config/define.h +++ b/src/config/define.h @@ -16,9 +16,9 @@ typedef enum cfgDefSectionStanza, // command-line or in any config stanza section } ConfigDefSection; -#include "config/config.h" -#include "config/define.auto.h" #include "common/type/string.h" +#include "config/config.auto.h" +#include "config/define.auto.h" /*********************************************************************************************************************************** Define global section name @@ -37,67 +37,67 @@ const char *cfgDefCommandHelpDescription(ConfigCommand commandId); const char *cfgDefCommandHelpSummary(ConfigCommand commandId); // Option allow lists -bool cfgDefOptionAllowList(ConfigCommand commandId, ConfigDefineOption optionDefId); -bool cfgDefOptionAllowListValueValid(ConfigCommand commandId, ConfigDefineOption optionDefId, const char *value); +bool cfgDefOptionAllowList(ConfigCommand commandId, ConfigOption optionId); +bool cfgDefOptionAllowListValueValid(ConfigCommand commandId, ConfigOption optionId, const char *value); // Allow range -bool cfgDefOptionAllowRange(ConfigCommand commandId, ConfigDefineOption optionDefId); -double cfgDefOptionAllowRangeMax(ConfigCommand commandId, ConfigDefineOption optionDefId); -double cfgDefOptionAllowRangeMin(ConfigCommand commandId, ConfigDefineOption optionDefId); +bool cfgDefOptionAllowRange(ConfigCommand commandId, ConfigOption optionId); +double cfgDefOptionAllowRangeMax(ConfigCommand commandId, ConfigOption optionId); +double cfgDefOptionAllowRangeMin(ConfigCommand commandId, ConfigOption optionId); // Default value for the option -const char *cfgDefOptionDefault(ConfigCommand commandId, ConfigDefineOption optionDefId); +const char *cfgDefOptionDefault(ConfigCommand commandId, ConfigOption optionId); // Dependencies and depend lists -bool cfgDefOptionDepend(ConfigCommand commandId, ConfigDefineOption optionDefId); -ConfigDefineOption cfgDefOptionDependOption(ConfigCommand commandId, ConfigDefineOption optionDefId); -unsigned int cfgDefOptionDependValueTotal(ConfigCommand commandId, ConfigDefineOption optionDefId); -bool cfgDefOptionDependValueValid(ConfigCommand commandId, ConfigDefineOption optionDefId, const char *value); -const char *cfgDefOptionDependValue(ConfigCommand commandId, ConfigDefineOption optionDefId, unsigned int valueId); +bool cfgDefOptionDepend(ConfigCommand commandId, ConfigOption optionId); +ConfigOption cfgDefOptionDependOption(ConfigCommand commandId, ConfigOption optionId); +unsigned int cfgDefOptionDependValueTotal(ConfigCommand commandId, ConfigOption optionId); +bool cfgDefOptionDependValueValid(ConfigCommand commandId, ConfigOption optionId, const char *value); +const char *cfgDefOptionDependValue(ConfigCommand commandId, ConfigOption optionId, unsigned int valueId); // Option help -const char *cfgDefOptionHelpDescription(ConfigCommand commandId, ConfigDefineOption optionDefId); -const char *cfgDefOptionHelpSummary(ConfigCommand commandId, ConfigDefineOption optionDefId); +const char *cfgDefOptionHelpDescription(ConfigCommand commandId, ConfigOption optionId); +const char *cfgDefOptionHelpSummary(ConfigCommand commandId, ConfigOption optionId); // Option help name alt -bool cfgDefOptionHelpNameAlt(ConfigDefineOption optionDefId); -const char *cfgDefOptionHelpNameAltValue(ConfigDefineOption optionDefId, unsigned int valueId); -unsigned int cfgDefOptionHelpNameAltValueTotal(ConfigDefineOption optionDefId); +bool cfgDefOptionHelpNameAlt(ConfigOption optionId); +const char *cfgDefOptionHelpNameAltValue(ConfigOption optionId, unsigned int valueId); +unsigned int cfgDefOptionHelpNameAltValueTotal(ConfigOption optionId); // Option help section -const char *cfgDefOptionHelpSection(ConfigDefineOption optionDefId); +const char *cfgDefOptionHelpSection(ConfigOption optionId); // Option id by name int cfgDefOptionId(const char *optionName); // Total indexed values for option -unsigned int cfgDefOptionIndexTotal(ConfigDefineOption optionDefId); +unsigned int cfgDefOptionIndexTotal(ConfigOption optionId); // Is the option for internal use only? -bool cfgDefOptionInternal(ConfigCommand commandId, ConfigDefineOption optionDefId); +bool cfgDefOptionInternal(ConfigCommand commandId, ConfigOption optionId); // Does the option accept multiple values? -bool cfgDefOptionMulti(ConfigDefineOption optionDefId); +bool cfgDefOptionMulti(ConfigOption optionId); // Name of the option -const char *cfgDefOptionName(ConfigDefineOption optionDefId); +const char *cfgDefOptionName(ConfigOption optionId); // Is the option required -bool cfgDefOptionRequired(ConfigCommand commandId, ConfigDefineOption optionDefId); +bool cfgDefOptionRequired(ConfigCommand commandId, ConfigOption optionId); // Get option section -ConfigDefSection cfgDefOptionSection(ConfigDefineOption optionDefId); +ConfigDefSection cfgDefOptionSection(ConfigOption optionId); // Does the option need to be protected from showing up in logs, command lines, etc? -bool cfgDefOptionSecure(ConfigDefineOption optionDefId); +bool cfgDefOptionSecure(ConfigOption optionId); // Option total unsigned int cfgDefOptionTotal(void); // Get option data type -int cfgDefOptionType(ConfigDefineOption optionDefId); +int cfgDefOptionType(ConfigOption optionId); // Is the option valid for the command? -bool cfgDefOptionValid(ConfigCommand commandId, ConfigDefineOption optionDefId); +bool cfgDefOptionValid(ConfigCommand commandId, ConfigOption optionId); #endif diff --git a/src/config/exec.c b/src/config/exec.c index 82b53ef9a..cd446d6e5 100644 --- a/src/config/exec.c +++ b/src/config/exec.c @@ -8,6 +8,7 @@ Exec Configuration #include "common/debug.h" #include "common/log.h" #include "config/define.h" +#include "config/config.intern.h" #include "config/exec.h" /**********************************************************************************************************************************/ @@ -31,95 +32,100 @@ cfgExecParam(ConfigCommand commandId, ConfigCommandRole commandRoleId, const Key for (ConfigOption optionId = 0; optionId < CFG_OPTION_TOTAL; optionId++) { - ConfigDefineOption optionDefId = cfgOptionDefIdFromId(optionId); - - // Skip the option if it is not valid for the specified command or if is secure. Also skip repo1-cipher-type because - // there's no point of passing it if the other process doesn't have access to repo1-cipher-pass. There is probably a - // better way to do this... - if (!cfgDefOptionValid(commandId, optionDefId) || cfgDefOptionSecure(optionDefId) || - optionDefId == cfgDefOptRepoCipherType) + // Skip the option if it is not valid for the original/specified command or if is secure. Also skip repo1-cipher-type + // because there's no point of passing it if the other process doesn't have access to repo1-cipher-pass. There is + // probably a better way to do this last part... + if (!cfgDefOptionValid(commandId, optionId) || cfgDefOptionSecure(optionId) || optionId == cfgOptRepoCipherType) { continue; } - // First check for a replacement - const Variant *key = VARSTRZ(cfgOptionName(optionId)); - const Variant *value = NULL; - bool exists = false; + // Loop through option indexes + unsigned int optionIdxTotal = cfgOptionGroup(optionId) ? cfgOptionGroupIdxTotal(cfgOptionGroupId(optionId)) : 1; - if (optionReplace != NULL) + for (unsigned int optionIdx = 0; optionIdx < optionIdxTotal; optionIdx++) { - exists = kvKeyExists(optionReplace, key); + // First check for a replacement + const Variant *key = VARSTRZ(cfgOptionIdxName(optionId, optionIdx)); + const Variant *value = NULL; + bool exists = false; - if (exists) - value = kvGet(optionReplace, key); - } - - // If the key exists but is NULL then skip this option - if (exists && value == NULL) - continue; - - // If no replacement then see if this option is valid for the current command and is not default - if (value == NULL && cfgOptionValid(optionId)) - { - if (cfgOptionNegate(optionId)) - value = BOOL_FALSE_VAR; - else if (cfgOptionSource(optionId) != cfgSourceDefault) - value = cfgOption(optionId); - } - - // If the option was reset - if (value == NULL && cfgOptionReset(optionId)) - { - strLstAdd(result, strNewFmt("--reset-%s", cfgOptionName(optionId))); - } - // Else format the value if found - else if (value != NULL && (!local || exists || cfgOptionSource(optionId) == cfgSourceParam)) - { - if (varType(value) == varTypeBool) + // If an option is requested to be replaced (usually because remote processes do not have access to the config) + // then if the option exists, get the new value for replacement + if (optionReplace != NULL) { - strLstAdd(result, strNewFmt("--%s%s", varBool(value) ? "" : "no-", cfgOptionName(optionId))); + exists = kvKeyExists(optionReplace, key); + + if (exists) + value = kvGet(optionReplace, key); } - else + + // If the key exists but its value is NULL then skip this option + if (exists && value == NULL) + continue; + + // If no replacement then see if this option is not default + if (value == NULL && cfgOptionValid(optionId)) { - StringList *valueList = NULL; + if (cfgOptionIdxNegate(optionId, optionIdx)) + value = BOOL_FALSE_VAR; + else if (cfgOptionIdxSource(optionId, optionIdx) != cfgSourceDefault) + value = cfgOptionIdx(optionId, optionIdx); + } - if (varType(value) == varTypeKeyValue) + // If the option was reset + if (value == NULL && cfgOptionValid(optionId) && cfgOptionIdxReset(optionId, optionIdx)) + { + strLstAdd(result, strNewFmt("--reset-%s", cfgOptionIdxName(optionId, optionIdx))); + } + // Else format the value if found, even if the option is not valid for the command + else if (value != NULL && (!local || exists || cfgOptionIdxSource(optionId, optionIdx) == cfgSourceParam)) + { + if (varType(value) == varTypeBool) { - valueList = strLstNew(); - - const KeyValue *optionKv = varKv(value); - const VariantList *keyList = kvKeyList(optionKv); - - for (unsigned int keyIdx = 0; keyIdx < varLstSize(keyList); keyIdx++) - { - strLstAdd( - valueList, - strNewFmt( - "%s=%s", strZ(varStr(varLstGet(keyList, keyIdx))), - strZ(varStrForce(kvGet(optionKv, varLstGet(keyList, keyIdx)))))); - } + strLstAdd(result, strNewFmt("--%s%s", varBool(value) ? "" : "no-", cfgOptionIdxName(optionId, optionIdx))); } - else if (varType(value) == varTypeVariantList) - { - valueList = strLstNewVarLst(varVarLst(value)); - } - // Else only one value else { - valueList = strLstNew(); - strLstAdd(valueList, varStrForce(value)); - } + StringList *valueList = NULL; - // Output options and values - for (unsigned int valueListIdx = 0; valueListIdx < strLstSize(valueList); valueListIdx++) - { - const String *value = strLstGet(valueList, valueListIdx); + if (varType(value) == varTypeKeyValue) + { + valueList = strLstNew(); - if (quote && strchr(strZ(value), ' ') != NULL) - value = strNewFmt("\"%s\"", strZ(value)); + const KeyValue *optionKv = varKv(value); + const VariantList *keyList = kvKeyList(optionKv); - strLstAdd(result, strNewFmt("--%s=%s", cfgOptionName(optionId), strZ(value))); + for (unsigned int keyIdx = 0; keyIdx < varLstSize(keyList); keyIdx++) + { + strLstAdd( + valueList, + strNewFmt( + "%s=%s", strZ(varStr(varLstGet(keyList, keyIdx))), + strZ(varStrForce(kvGet(optionKv, varLstGet(keyList, keyIdx)))))); + } + } + else if (varType(value) == varTypeVariantList) + { + valueList = strLstNewVarLst(varVarLst(value)); + } + // Else only one value + else + { + valueList = strLstNew(); + strLstAdd(valueList, varStrForce(value)); + } + + // Output options and values + for (unsigned int valueListIdx = 0; valueListIdx < strLstSize(valueList); valueListIdx++) + { + const String *value = strLstGet(valueList, valueListIdx); + + if (quote && strchr(strZ(value), ' ') != NULL) + value = strNewFmt("\"%s\"", strZ(value)); + + strLstAdd(result, strNewFmt("--%s=%s", cfgOptionIdxName(optionId, optionIdx), strZ(value))); + } } } } diff --git a/src/config/load.c b/src/config/load.c index 4747794cb..ea3b4ebbe 100644 --- a/src/config/load.c +++ b/src/config/load.c @@ -16,8 +16,7 @@ Configuration Load #include "common/io/socket/common.h" #include "common/lock.h" #include "common/log.h" -#include "config/config.h" -#include "config/define.h" +#include "config/config.intern.h" #include "config/load.h" #include "config/parse.h" #include "storage/helper.h" @@ -68,18 +67,12 @@ cfgLoadUpdateOption(void) FUNCTION_LOG_VOID(logLevelTrace); // Set default for repo-host-cmd - if (cfgOptionTest(cfgOptRepoHost) && cfgOptionSource(cfgOptRepoHostCmd) == cfgSourceDefault) + if (cfgOptionValid(cfgOptRepoHostCmd)) cfgOptionDefaultSet(cfgOptRepoHostCmd, VARSTR(cfgExe())); // Set default for pg-host-cmd if (cfgOptionValid(cfgOptPgHostCmd)) - { - for (unsigned int optionIdx = 0; optionIdx < cfgOptionGroupIdxTotal(cfgOptGrpPg); optionIdx++) - { - if (cfgOptionTest(cfgOptPgHost + optionIdx) && cfgOptionSource(cfgOptPgHostCmd + optionIdx) == cfgSourceDefault) - cfgOptionDefaultSet(cfgOptPgHostCmd + optionIdx, VARSTR(cfgExe())); - } - } + cfgOptionDefaultSet(cfgOptPgHostCmd, VARSTR(cfgExe())); // Protocol timeout should be greater than db timeout if (cfgOptionTest(cfgOptDbTimeout) && cfgOptionTest(cfgOptProtocolTimeout) && @@ -119,7 +112,7 @@ cfgLoadUpdateOption(void) for (unsigned int optionIdx = 0; optionIdx < cfgOptionGroupIdxTotal(cfgOptGrpPg); optionIdx++) { - if (cfgOptionTest(cfgOptPgHost + optionIdx)) + if (cfgOptionIdxTest(cfgOptPgHost, optionIdx)) { pgHostFound = true; break; @@ -131,7 +124,7 @@ cfgLoadUpdateOption(void) { for (unsigned int optionIdx = 0; optionIdx < cfgOptionGroupIdxTotal(cfgOptGrpRepo); optionIdx++) { - if (cfgOptionTest(cfgOptRepoHost + optionIdx)) + if (cfgOptionIdxTest(cfgOptRepoHost, optionIdx)) THROW_FMT(ConfigError, "pg and repo hosts cannot both be configured as remote"); } } @@ -142,15 +135,14 @@ cfgLoadUpdateOption(void) { for (unsigned int optionIdx = 0; optionIdx < cfgOptionGroupIdxTotal(cfgOptGrpRepo); optionIdx++) { - // If the repo-type is defined, then see if corresponding retention-full is set - if (cfgOptionTest(cfgOptRepoType + optionIdx) && !(cfgOptionTest(cfgOptRepoRetentionFull + optionIdx))) + if (!(cfgOptionIdxTest(cfgOptRepoRetentionFull, optionIdx))) { LOG_WARN_FMT( "option '%s' is not set for '%s=%s', the repository may run out of space" "\nHINT: to retain full backups indefinitely (without warning), set option '%s' to the maximum.", - cfgOptionName(cfgOptRepoRetentionFull + optionIdx), cfgOptionName(cfgOptRepoRetentionFullType + optionIdx), - strZ(cfgOptionStr(cfgOptRepoRetentionFullType + optionIdx)), - cfgOptionName(cfgOptRepoRetentionFull + optionIdx)); + cfgOptionIdxName(cfgOptRepoRetentionFull, optionIdx), cfgOptionIdxName(cfgOptRepoRetentionFullType, optionIdx), + strZ(cfgOptionIdxStr(cfgOptRepoRetentionFullType, optionIdx)), + cfgOptionIdxName(cfgOptRepoRetentionFull, optionIdx)); } } } @@ -161,41 +153,43 @@ cfgLoadUpdateOption(void) // For each possible repo, check and adjust the settings as appropriate for (unsigned int optionIdx = 0; optionIdx < cfgOptionGroupIdxTotal(cfgOptGrpRepo); optionIdx++) { - const String *archiveRetentionType = cfgOptionStr(cfgOptRepoRetentionArchiveType + optionIdx); + const String *archiveRetentionType = cfgOptionIdxStr(cfgOptRepoRetentionArchiveType, optionIdx); const String *msgArchiveOff = strNewFmt( - "WAL segments will not be expired: option '%s=%s' but", cfgOptionName(cfgOptRepoRetentionArchiveType + optionIdx), + "WAL segments will not be expired: option '%s=%s' but", cfgOptionIdxName(cfgOptRepoRetentionArchiveType, optionIdx), strZ(archiveRetentionType)); // If the archive retention is not explicitly set then determine what it should be defaulted to - if (!cfgOptionTest(cfgOptRepoRetentionArchive + optionIdx)) + if (!cfgOptionIdxTest(cfgOptRepoRetentionArchive, optionIdx)) { // If repo-retention-archive-type is default (full), then if repo-retention-full is set, set the // repo-retention-archive to this value when retention-full-type is 'count', else ignore archiving. If // retention-full-type is 'time' then the the expire command will default the archive retention accordingly. if (strEqZ(archiveRetentionType, CFGOPTVAL_TMP_REPO_RETENTION_ARCHIVE_TYPE_FULL)) { - if (strEqZ(cfgOptionStr(cfgOptRepoRetentionFullType + optionIdx), CFGOPTVAL_TMP_REPO_RETENTION_FULL_TYPE_COUNT) - && cfgOptionTest(cfgOptRepoRetentionFull + optionIdx)) + if (strEqZ( + cfgOptionIdxStr(cfgOptRepoRetentionFullType, optionIdx), + CFGOPTVAL_TMP_REPO_RETENTION_FULL_TYPE_COUNT) && + cfgOptionIdxTest(cfgOptRepoRetentionFull, optionIdx)) { - cfgOptionSet(cfgOptRepoRetentionArchive + optionIdx, cfgSourceDefault, - VARUINT(cfgOptionUInt(cfgOptRepoRetentionFull + optionIdx))); + cfgOptionIdxSet(cfgOptRepoRetentionArchive, optionIdx, cfgSourceDefault, + VARUINT(cfgOptionIdxUInt(cfgOptRepoRetentionFull, optionIdx))); } } else if (strEqZ(archiveRetentionType, CFGOPTVAL_TMP_REPO_RETENTION_ARCHIVE_TYPE_DIFF)) { // if repo-retention-diff is set then user must have set it - if (cfgOptionTest(cfgOptRepoRetentionDiff + optionIdx)) + if (cfgOptionIdxTest(cfgOptRepoRetentionDiff, optionIdx)) { - cfgOptionSet(cfgOptRepoRetentionArchive + optionIdx, cfgSourceDefault, - VARUINT(cfgOptionUInt(cfgOptRepoRetentionDiff + optionIdx))); + cfgOptionIdxSet(cfgOptRepoRetentionArchive, optionIdx, cfgSourceDefault, + VARUINT(cfgOptionIdxUInt(cfgOptRepoRetentionDiff, optionIdx))); } else { LOG_WARN_FMT( "%s neither option '%s' nor option '%s' is set", strZ(msgArchiveOff), - cfgOptionName(cfgOptRepoRetentionArchive + optionIdx), - cfgOptionName(cfgOptRepoRetentionDiff + optionIdx)); + cfgOptionIdxName(cfgOptRepoRetentionArchive, optionIdx), + cfgOptionIdxName(cfgOptRepoRetentionDiff, optionIdx)); } } else @@ -204,7 +198,7 @@ cfgLoadUpdateOption(void) LOG_WARN_FMT( "%s option '%s' is not set", strZ(msgArchiveOff), - cfgOptionName(cfgOptRepoRetentionArchive + optionIdx)); + cfgOptionIdxName(cfgOptRepoRetentionArchive, optionIdx)); } } else @@ -213,21 +207,21 @@ cfgLoadUpdateOption(void) // corresponding setting is UNDEF since UNDEF means backups will not be expired but they should be in the // practice of setting this value even though expiring the archive itself is OK and will be performed. if ((strEqZ(archiveRetentionType, CFGOPTVAL_TMP_REPO_RETENTION_ARCHIVE_TYPE_DIFF)) && - (!cfgOptionTest(cfgOptRepoRetentionDiff + optionIdx))) + (!cfgOptionIdxTest(cfgOptRepoRetentionDiff, optionIdx))) { LOG_WARN_FMT("option '%s' is not set for '%s=%s'\n" "HINT: to retain differential backups indefinitely (without warning), set option '%s' to the maximum.", - cfgOptionName(cfgOptRepoRetentionDiff + optionIdx), - cfgOptionName(cfgOptRepoRetentionArchiveType + optionIdx), + cfgOptionIdxName(cfgOptRepoRetentionDiff, optionIdx), + cfgOptionIdxName(cfgOptRepoRetentionArchiveType, optionIdx), CFGOPTVAL_TMP_REPO_RETENTION_ARCHIVE_TYPE_DIFF, - cfgOptionName(cfgOptRepoRetentionDiff + optionIdx)); + cfgOptionIdxName(cfgOptRepoRetentionDiff, optionIdx)); } } } } // Error if an S3 bucket name contains dots - if (cfgOptionTest(cfgOptRepoS3Bucket) && cfgOptionBool(cfgOptRepoS3VerifyTls) && + if (cfgOptionGroupValid(cfgOptGrpRepo) && cfgOptionTest(cfgOptRepoS3Bucket) && cfgOptionBool(cfgOptRepoS3VerifyTls) && strChr(cfgOptionStr(cfgOptRepoS3Bucket), '.') != -1) { THROW_FMT( @@ -258,7 +252,7 @@ cfgLoadUpdateOption(void) } // Now invalidate compress so it can't be used and won't be passed to child processes - cfgOptionValidSet(cfgOptCompress, false); + cfgOptionInvalidate(cfgOptCompress); cfgOptionSet(cfgOptCompress, cfgSourceDefault, NULL); } diff --git a/src/config/parse.auto.c b/src/config/parse.auto.c index 3e620a777..659c81c61 100644 --- a/src/config/parse.auto.c +++ b/src/config/parse.auto.c @@ -348,14 +348,6 @@ static const struct option optionList[] = .val = PARSE_OPTION_FLAG | cfgOptForce, }, - // host-id option - // ----------------------------------------------------------------------------------------------------------------------------- - { - .name = "host-id", - .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptHostId, - }, - // ignore-missing option // ----------------------------------------------------------------------------------------------------------------------------- { @@ -538,6 +530,18 @@ static const struct option optionList[] = .val = PARSE_OPTION_FLAG | cfgOptOutput, }, + // pg option + // ----------------------------------------------------------------------------------------------------------------------------- + { + .name = "pg", + .has_arg = required_argument, + .val = PARSE_OPTION_FLAG | cfgOptPg, + }, + { + .name = "reset-pg", + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptPg, + }, + // pg-host option and deprecations // ----------------------------------------------------------------------------------------------------------------------------- { @@ -1888,6 +1892,18 @@ static const struct option optionList[] = .val = PARSE_OPTION_FLAG | cfgOptRemoteType, }, + // repo option + // ----------------------------------------------------------------------------------------------------------------------------- + { + .name = "repo", + .has_arg = required_argument, + .val = PARSE_OPTION_FLAG | cfgOptRepo, + }, + { + .name = "reset-repo", + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptRepo, + }, + // repo-azure-account option // ----------------------------------------------------------------------------------------------------------------------------- { @@ -2779,7 +2795,6 @@ static const ConfigOption optionResolveOrder[] = cfgOptExecId, cfgOptExpireAuto, cfgOptFilter, - cfgOptHostId, cfgOptIgnoreMissing, cfgOptIoTimeout, cfgOptLinkAll, @@ -2795,52 +2810,19 @@ static const ConfigOption optionResolveOrder[] = cfgOptNeutralUmask, cfgOptOnline, cfgOptOutput, + cfgOptPg, cfgOptPgLocal, - cfgOptPgLocal + 1, - cfgOptPgLocal + 2, - cfgOptPgLocal + 3, - cfgOptPgLocal + 4, - cfgOptPgLocal + 5, - cfgOptPgLocal + 6, - cfgOptPgLocal + 7, cfgOptPgPath, - cfgOptPgPath + 1, - cfgOptPgPath + 2, - cfgOptPgPath + 3, - cfgOptPgPath + 4, - cfgOptPgPath + 5, - cfgOptPgPath + 6, - cfgOptPgPath + 7, cfgOptPgPort, - cfgOptPgPort + 1, - cfgOptPgPort + 2, - cfgOptPgPort + 3, - cfgOptPgPort + 4, - cfgOptPgPort + 5, - cfgOptPgPort + 6, - cfgOptPgPort + 7, cfgOptPgSocketPath, - cfgOptPgSocketPath + 1, - cfgOptPgSocketPath + 2, - cfgOptPgSocketPath + 3, - cfgOptPgSocketPath + 4, - cfgOptPgSocketPath + 5, - cfgOptPgSocketPath + 6, - cfgOptPgSocketPath + 7, cfgOptPgUser, - cfgOptPgUser + 1, - cfgOptPgUser + 2, - cfgOptPgUser + 3, - cfgOptPgUser + 4, - cfgOptPgUser + 5, - cfgOptPgUser + 6, - cfgOptPgUser + 7, cfgOptProcess, cfgOptProcessMax, cfgOptProtocolTimeout, cfgOptRaw, cfgOptRecurse, cfgOptRemoteType, + cfgOptRepo, cfgOptRepoCipherType, cfgOptRepoHardlink, cfgOptRepoLocal, @@ -2869,61 +2851,12 @@ static const ConfigOption optionResolveOrder[] = cfgOptArchiveCopy, cfgOptForce, cfgOptPgHost, - cfgOptPgHost + 1, - cfgOptPgHost + 2, - cfgOptPgHost + 3, - cfgOptPgHost + 4, - cfgOptPgHost + 5, - cfgOptPgHost + 6, - cfgOptPgHost + 7, cfgOptPgHostCmd, - cfgOptPgHostCmd + 1, - cfgOptPgHostCmd + 2, - cfgOptPgHostCmd + 3, - cfgOptPgHostCmd + 4, - cfgOptPgHostCmd + 5, - cfgOptPgHostCmd + 6, - cfgOptPgHostCmd + 7, cfgOptPgHostConfig, - cfgOptPgHostConfig + 1, - cfgOptPgHostConfig + 2, - cfgOptPgHostConfig + 3, - cfgOptPgHostConfig + 4, - cfgOptPgHostConfig + 5, - cfgOptPgHostConfig + 6, - cfgOptPgHostConfig + 7, cfgOptPgHostConfigIncludePath, - cfgOptPgHostConfigIncludePath + 1, - cfgOptPgHostConfigIncludePath + 2, - cfgOptPgHostConfigIncludePath + 3, - cfgOptPgHostConfigIncludePath + 4, - cfgOptPgHostConfigIncludePath + 5, - cfgOptPgHostConfigIncludePath + 6, - cfgOptPgHostConfigIncludePath + 7, cfgOptPgHostConfigPath, - cfgOptPgHostConfigPath + 1, - cfgOptPgHostConfigPath + 2, - cfgOptPgHostConfigPath + 3, - cfgOptPgHostConfigPath + 4, - cfgOptPgHostConfigPath + 5, - cfgOptPgHostConfigPath + 6, - cfgOptPgHostConfigPath + 7, cfgOptPgHostPort, - cfgOptPgHostPort + 1, - cfgOptPgHostPort + 2, - cfgOptPgHostPort + 3, - cfgOptPgHostPort + 4, - cfgOptPgHostPort + 5, - cfgOptPgHostPort + 6, - cfgOptPgHostPort + 7, cfgOptPgHostUser, - cfgOptPgHostUser + 1, - cfgOptPgHostUser + 2, - cfgOptPgHostUser + 3, - cfgOptPgHostUser + 4, - cfgOptPgHostUser + 5, - cfgOptPgHostUser + 6, - cfgOptPgHostUser + 7, cfgOptRecoveryOption, cfgOptRepoAzureAccount, cfgOptRepoAzureCaFile, diff --git a/src/config/parse.c b/src/config/parse.c index a124eb004..a461072f7 100644 --- a/src/config/parse.c +++ b/src/config/parse.c @@ -14,6 +14,7 @@ Command and Option Parse #include "common/log.h" #include "common/memContext.h" #include "common/regExp.h" +#include "config/config.intern.h" #include "config/define.h" #include "config/parse.h" #include "storage/helper.h" @@ -43,8 +44,8 @@ Standard config include path name /*********************************************************************************************************************************** Option value constants ***********************************************************************************************************************************/ -VARIANT_STRDEF_STATIC(OPTION_VALUE_0, "0"); -VARIANT_STRDEF_STATIC(OPTION_VALUE_1, "1"); +VARIANT_STRDEF_STATIC(OPTION_VALUE_0, ZERO_Z); +VARIANT_STRDEF_STATIC(OPTION_VALUE_1, ONE_Z); /*********************************************************************************************************************************** Parse option flags @@ -76,19 +77,81 @@ Include automatically generated data structure for getopt_long() /*********************************************************************************************************************************** Struct to hold options parsed from the command line ***********************************************************************************************************************************/ -typedef struct ParseOption +typedef struct ParseOptionValue { bool found:1; // Was the option found? bool negate:1; // Was the option negated on the command line? bool reset:1; // Was the option reset on the command line? unsigned int source:2; // Where was the option found? StringList *valueList; // List of values found +} ParseOptionValue; + +typedef struct ParseOption +{ + unsigned int indexListTotal; // Total options in indexed list + ParseOptionValue *indexList; // List of indexed option values } ParseOption; #define FUNCTION_LOG_PARSE_OPTION_FORMAT(value, buffer, bufferSize) \ typeToLog("ParseOption", buffer, bufferSize) -/**********************************************************************************************************************************/ +/*********************************************************************************************************************************** +Get the indexed value, creating the array to contain it if needed +***********************************************************************************************************************************/ +static ParseOptionValue * +parseOptionIdxValue(ParseOption *optionList, unsigned int optionId, unsigned int optionKeyIdx) +{ + FUNCTION_TEST_BEGIN(); + FUNCTION_TEST_PARAM(PARSE_OPTION, parseOption); // Structure containing all options being parsed + FUNCTION_TEST_PARAM(UINT, optionId); // Unique ID which also identifies the option in the parse list + FUNCTION_TEST_PARAM(UINT, optionKeyIdx); // Zero-based key index (e.g. pg3-path => 2), 0 for non-indexed + FUNCTION_TEST_END(); + + // If the requested index is beyond what has already been allocated + if (optionKeyIdx >= optionList[optionId].indexListTotal) + { + // If the option is in a group + if (cfgOptionGroup(optionId)) + { + unsigned int optionOffset = 0; + + // Allocate enough memory to include the requested indexed or a fixed amount to avoid too many allocations + if (optionList[optionId].indexListTotal == 0) + { + optionList[optionId].indexListTotal = + optionKeyIdx >= (LIST_INITIAL_SIZE / 2) ? optionKeyIdx + 1 : (LIST_INITIAL_SIZE / 2); + optionList[optionId].indexList = memNew(sizeof(ParseOptionValue) * optionList[optionId].indexListTotal); + } + // Allocate more memory when needed. This could be more efficient but the limited number of indexes currently allowed + // makes it difficult to get coverage on a better implementation. + else + { + optionOffset = optionList[optionId].indexListTotal; + optionList[optionId].indexListTotal = optionKeyIdx + 1; + optionList[optionId].indexList = memResize( + optionList[optionId].indexList, sizeof(ParseOptionValue) * optionList[optionId].indexListTotal); + } + + // Initialize the newly allocated memory + for (unsigned int optKeyIdx = optionOffset; optKeyIdx < optionList[optionId].indexListTotal; optKeyIdx++) + optionList[optionId].indexList[optKeyIdx] = (ParseOptionValue){0}; + } + // Else the option is not in a group so there can only be one value + else + { + optionList[optionId].indexList = memNew(sizeof(ParseOptionValue)); + optionList[optionId].indexListTotal = 1; + optionList[optionId].indexList[0] = (ParseOptionValue){0}; + } + } + + // Return the indexed value + FUNCTION_TEST_RETURN(&optionList[optionId].indexList[optionKeyIdx]); +} + +/*********************************************************************************************************************************** +Find an option by name in the option list +***********************************************************************************************************************************/ // Helper to parse the option info into a structure __attribute__((always_inline)) static inline CfgParseOptionResult cfgParseOptionInfo(int info) @@ -96,7 +159,8 @@ cfgParseOptionInfo(int info) return (CfgParseOptionResult) { .found = true, - .id = (info & PARSE_OPTION_MASK) + ((info >> PARSE_KEY_IDX_SHIFT) & PARSE_KEY_IDX_MASK), + .id = info & PARSE_OPTION_MASK, + .keyIdx = (info >> PARSE_KEY_IDX_SHIFT) & PARSE_KEY_IDX_MASK, .negate = info & PARSE_NEGATE_FLAG, .reset = info & PARSE_RESET_FLAG, .deprecated = info & PARSE_DEPRECATE_FLAG, @@ -333,24 +397,27 @@ cfgFileLoad( // NOTE: Pas // If the option is specified on the command line, then found will be true meaning the file is required to exist, // else it is optional - bool configRequired = optionList[cfgOptConfig].found; - bool configIncludeRequired = optionList[cfgOptConfigIncludePath].found; + bool configFound = optionList[cfgOptConfig].indexList != NULL && optionList[cfgOptConfig].indexList[0].found; + bool configRequired = configFound; + bool configPathRequired = optionList[cfgOptConfigPath].indexList != NULL && optionList[cfgOptConfigPath].indexList[0].found; + bool configIncludeRequired = + optionList[cfgOptConfigIncludePath].indexList != NULL && optionList[cfgOptConfigIncludePath].indexList[0].found; // Save default for later determining if must check old original default config path const String *optConfigDefaultCurrent = optConfigDefault; // If the config-path option is found on the command line, then its value will override the base path defaults for config and // config-include-path - if (optionList[cfgOptConfigPath].found) + if (configPathRequired) { - optConfigDefault = - strNewFmt("%s/%s", strZ(strLstGet(optionList[cfgOptConfigPath].valueList, 0)), strBaseZ(optConfigDefault)); - optConfigIncludePathDefault = - strNewFmt("%s/%s", strZ(strLstGet(optionList[cfgOptConfigPath].valueList, 0)), PGBACKREST_CONFIG_INCLUDE_PATH); + optConfigDefault = strNewFmt( + "%s/%s", strZ(strLstGet(optionList[cfgOptConfigPath].indexList[0].valueList, 0)), strBaseZ(optConfigDefault)); + optConfigIncludePathDefault = strNewFmt( + "%s/%s", strZ(strLstGet(optionList[cfgOptConfigPath].indexList[0].valueList, 0)), PGBACKREST_CONFIG_INCLUDE_PATH); } // If the --no-config option was passed then do not load the config file - if (optionList[cfgOptConfig].negate) + if (optionList[cfgOptConfig].indexList != NULL && optionList[cfgOptConfig].indexList[0].negate) { loadConfig = false; configRequired = false; @@ -358,7 +425,7 @@ cfgFileLoad( // NOTE: Pas // If --config option is specified on the command line but neither the --config-include-path nor the config-path are passed, // then do not attempt to load the include files - if (optionList[cfgOptConfig].found && !(optionList[cfgOptConfigIncludePath].found || optionList[cfgOptConfigPath].found)) + if (configFound && !(configPathRequired || configIncludeRequired)) { loadConfigInclude = false; configIncludeRequired = false; @@ -372,8 +439,8 @@ cfgFileLoad( // NOTE: Pas const String *configFileName = NULL; // Get the config file name from the command-line if it exists else default - if (optionList[cfgOptConfig].found) - configFileName = strLstGet(optionList[cfgOptConfig].valueList, 0); + if (configRequired) + configFileName = strLstGet(optionList[cfgOptConfig].indexList[0].valueList, 0); else configFileName = optConfigDefault; @@ -385,7 +452,7 @@ cfgFileLoad( // NOTE: Pas result = strNewBuf(buffer); else if (strEq(configFileName, optConfigDefaultCurrent)) { - // If confg is current default and it was not found, attempt to load the config file from the old default location + // If config is current default and it was not found, attempt to load the config file from the old default location buffer = storageGetP(storageNewReadP(storageLocal(), origConfigDefault, .ignoreMissing = !configRequired)); if (buffer != NULL) @@ -406,8 +473,8 @@ cfgFileLoad( // NOTE: Pas const String *configIncludePath = NULL; // Get the config include path from the command-line if it exists else default - if (optionList[cfgOptConfigIncludePath].found) - configIncludePath = strLstGet(optionList[cfgOptConfigIncludePath].valueList, 0); + if (configIncludeRequired) + configIncludePath = strLstGet(optionList[cfgOptConfigIncludePath].indexList[0].valueList, 0); else configIncludePath = optConfigIncludePathDefault; @@ -449,20 +516,29 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel) FUNCTION_LOG_PARAM(CHARPY, argList); FUNCTION_LOG_END(); - // Initialize configuration - cfgInit(); - MEM_CONTEXT_TEMP_BEGIN() { - // Set the exe - cfgExeSet(STR(argList[0])); + // Create the config struct + Config *config; + + MEM_CONTEXT_NEW_BEGIN("Config") + { + config = memNew(sizeof(Config)); + + *config = (Config) + { + .memContext = MEM_CONTEXT_NEW(), + .command = cfgCmdNone, + .exe = strNew(argList[0]), + }; + } + MEM_CONTEXT_NEW_END(); // Phase 1: parse command line parameters // ------------------------------------------------------------------------------------------------------------------------- int optionValue; // Value returned by getopt_long int optionListIdx; // Index of option in list (if an option was returned) bool argFound = false; // Track args found to decide on error or help at the end - StringList *commandParamList = NULL; // List of command parameters // Reset optind to 1 in case getopt_long has been called before optind = 1; @@ -471,7 +547,7 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel) opterr = false; // List of parsed options - ParseOption parseOptionList[CFG_OPTION_TOTAL] = {{.found = false}}; + ParseOption parseOptionList[CFG_OPTION_TOTAL] = {{0}}; // Only the first non-option parameter should be treated as a command so track if the command has been set bool commandSet = false; @@ -489,44 +565,47 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel) const char *command = argList[optind - 1]; // Try getting the command from the valid command list - ConfigCommand commandId = cfgCommandId(command, false); - ConfigCommandRole commandRoleId = cfgCmdRoleDefault; + config->command = cfgCommandId(command); + config->commandRole = cfgCmdRoleDefault; // If not successful then a command role may be appended - if (commandId == cfgCmdNone) + if (config->command == cfgCmdNone) { const StringList *commandPart = strLstNewSplit(STR(command), COLON_STR); if (strLstSize(commandPart) == 2) { // Get command id - commandId = cfgCommandId(strZ(strLstGet(commandPart, 0)), false); + config->command = cfgCommandId(strZ(strLstGet(commandPart, 0))); // If command id is valid then get command role id - if (commandId != cfgCmdNone) - commandRoleId = cfgCommandRoleEnum(strLstGet(commandPart, 1)); + if (config->command != cfgCmdNone) + config->commandRole = cfgCommandRoleEnum(strLstGet(commandPart, 1)); } } // Error when command does not exist - if (commandId == cfgCmdNone) + if (config->command == cfgCmdNone) THROW_FMT(CommandInvalidError, "invalid command '%s'", command); - // Set the command - cfgCommandSet(commandId, commandRoleId); - - if (cfgCommand() == cfgCmdHelp) - cfgCommandHelpSet(true); + if (config->command == cfgCmdHelp) + config->help = true; else commandSet = true; } // Additional arguments are command arguments else { - if (commandParamList == NULL) - commandParamList = strLstNew(); + if (config->paramList == NULL) + { + MEM_CONTEXT_BEGIN(config->memContext) + { + config->paramList = strLstNew(); + } + MEM_CONTEXT_END(); + } - strLstAdd(commandParamList, STR(argList[optind - 1])); + strLstAdd(config->paramList, strNew(argList[optind - 1])); } break; @@ -550,66 +629,91 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel) ASSERT(option.id < CFG_OPTION_TOTAL); // Error if this option is secure and cannot be passed on the command line - if (cfgDefOptionSecure(cfgOptionDefIdFromId(option.id))) + if (cfgDefOptionSecure(option.id)) { THROW_FMT( OptionInvalidError, "option '%s' is not allowed on the command-line\n" "HINT: this option could expose secrets in the process list.\n" "HINT: specify the option in a configuration file or an environment variable instead.", - cfgOptionName(option.id)); + cfgOptionKeyIdxName(option.id, option.keyIdx)); } - // If the the option has not been found yet then set it - if (!parseOptionList[option.id].found) + // If the option has not been found yet then set it + ParseOptionValue *optionValue = parseOptionIdxValue(parseOptionList, option.id, option.keyIdx); + + if (!optionValue->found) { - parseOptionList[option.id].found = true; - parseOptionList[option.id].negate = option.negate; - parseOptionList[option.id].reset = option.reset; - parseOptionList[option.id].source = cfgSourceParam; + *optionValue = (ParseOptionValue) + { + .found = true, + .negate = option.negate, + .reset = option.reset, + .source = cfgSourceParam, + }; // Only set the argument if the option requires one if (optionList[optionListIdx].has_arg == required_argument) { - parseOptionList[option.id].valueList = strLstNew(); - strLstAdd(parseOptionList[option.id].valueList, STR(optarg)); + optionValue->valueList = strLstNew(); + strLstAdd(optionValue->valueList, STR(optarg)); } } else { // Make sure option is not negated more than once. It probably wouldn't hurt anything to accept this case // but there's no point in allowing the user to be sloppy. - if (parseOptionList[option.id].negate && option.negate) - THROW_FMT(OptionInvalidError, "option '%s' is negated multiple times", cfgOptionName(option.id)); + if (optionValue->negate && option.negate) + { + THROW_FMT( + OptionInvalidError, "option '%s' is negated multiple times", + cfgOptionKeyIdxName(option.id, option.keyIdx)); + } // Make sure option is not reset more than once. Same justification as negate. - if (parseOptionList[option.id].reset && option.reset) - THROW_FMT(OptionInvalidError, "option '%s' is reset multiple times", cfgOptionName(option.id)); + if (optionValue->reset && option.reset) + { + THROW_FMT( + OptionInvalidError, "option '%s' is reset multiple times", + cfgOptionKeyIdxName(option.id, option.keyIdx)); + } // Don't allow an option to be both negated and reset - if ((parseOptionList[option.id].reset && option.negate) || - (parseOptionList[option.id].negate && option.reset)) + if ((optionValue->reset && option.negate) || (optionValue->negate && option.reset)) { - THROW_FMT(OptionInvalidError, "option '%s' cannot be negated and reset", cfgOptionName(option.id)); + THROW_FMT( + OptionInvalidError, "option '%s' cannot be negated and reset", + cfgOptionKeyIdxName(option.id, option.keyIdx)); } // Don't allow an option to be both set and negated - if (parseOptionList[option.id].negate != option.negate) - THROW_FMT(OptionInvalidError, "option '%s' cannot be set and negated", cfgOptionName(option.id)); + if (optionValue->negate != option.negate) + { + THROW_FMT( + OptionInvalidError, "option '%s' cannot be set and negated", + cfgOptionKeyIdxName(option.id, option.keyIdx)); + } // Don't allow an option to be both set and reset - if (parseOptionList[option.id].reset != option.reset) - THROW_FMT(OptionInvalidError, "option '%s' cannot be set and reset", cfgOptionName(option.id)); + if (optionValue->reset != option.reset) + { + THROW_FMT( + OptionInvalidError, "option '%s' cannot be set and reset", + cfgOptionKeyIdxName(option.id, option.keyIdx)); + } // Add the argument - if (optionList[optionListIdx].has_arg == required_argument && - cfgDefOptionMulti(cfgOptionDefIdFromId(option.id))) + if (optionList[optionListIdx].has_arg == required_argument && cfgDefOptionMulti(option.id)) { - strLstAdd(parseOptionList[option.id].valueList, strNew(optarg)); + strLstAdd(optionValue->valueList, strNew(optarg)); } // Error if the option does not accept multiple arguments else - THROW_FMT(OptionInvalidError, "option '%s' cannot be set multiple times", cfgOptionName(option.id)); + { + THROW_FMT( + OptionInvalidError, "option '%s' cannot be set multiple times", + cfgOptionKeyIdxName(option.id, option.keyIdx)); + } } break; @@ -621,39 +725,30 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel) } // Handle command not found - if (!commandSet && !cfgCommandHelp()) + if (!commandSet && !config->help) { // If there are args then error if (argFound) THROW_FMT(CommandRequiredError, "no command found"); // Otherwise set the command to help - cfgCommandHelpSet(true); + config->help = true; } - // Set command params - if (commandParamList != NULL) - { - if (!cfgCommandHelp() && !cfgParameterAllowed()) - THROW(ParamInvalidError, "command does not allow parameters"); - - cfgCommandParamSet(commandParamList); - } + // Error when parameters found but the command does not allow parameters + if (config->paramList != NULL && !config->help && !cfgCommandParameterAllowed(config->command)) + THROW(ParamInvalidError, "command does not allow parameters"); // Enable logging (except for local and remote commands) so config file warnings will be output - if (cfgCommandRole() != cfgCmdRoleLocal && cfgCommandRole() != cfgCmdRoleRemote && resetLogLevel) + if (config->commandRole != cfgCmdRoleLocal && config->commandRole != cfgCmdRoleRemote && resetLogLevel) logInit(logLevelWarn, logLevelWarn, logLevelOff, false, 0, 1, false); // Only continue if command options need to be validated, i.e. a real command is running or we are getting help for a // specific command and would like to display actual option values in the help. - if (cfgCommand() != cfgCmdNone && - cfgCommand() != cfgCmdVersion && - cfgCommand() != cfgCmdHelp) + if (config->command != cfgCmdNone && config->command != cfgCmdVersion && config->command != cfgCmdHelp) { // Phase 2: parse environment variables // --------------------------------------------------------------------------------------------------------------------- - ConfigCommand commandId = cfgCommand(); - unsigned int environIdx = 0; // Loop through all environment variables and look for our env vars by matching the prefix @@ -696,40 +791,40 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel) continue; } - ConfigDefineOption optionDefId = cfgOptionDefIdFromId(option.id); - // Continue if the option is not valid for this command - if (!cfgDefOptionValid(commandId, optionDefId)) + if (!cfgDefOptionValid(config->command, option.id)) continue; if (strSize(value) == 0) THROW_FMT(OptionInvalidValueError, "environment variable '%s' must have a value", strZ(key)); // Continue if the option has already been specified on the command line - if (parseOptionList[option.id].found) + ParseOptionValue *optionValue = parseOptionIdxValue(parseOptionList, option.id, option.keyIdx); + + if (optionValue->found) continue; - parseOptionList[option.id].found = true; - parseOptionList[option.id].source = cfgSourceConfig; + optionValue->found = true; + optionValue->source = cfgSourceConfig; // Convert boolean to string - if (cfgDefOptionType(optionDefId) == cfgDefOptTypeBoolean) + if (cfgDefOptionType(option.id) == cfgDefOptTypeBoolean) { if (strEqZ(value, "n")) - parseOptionList[option.id].negate = true; + optionValue->negate = true; else if (!strEqZ(value, "y")) THROW_FMT(OptionInvalidValueError, "environment boolean option '%s' must be 'y' or 'n'", strZ(key)); } // Else split list/hash into separate values - else if (cfgDefOptionMulti(optionDefId)) + else if (cfgDefOptionMulti(option.id)) { - parseOptionList[option.id].valueList = strLstNewSplitZ(value, ":"); + optionValue->valueList = strLstNewSplitZ(value, ":"); } // Else add the string value else { - parseOptionList[option.id].valueList = strLstNew(); - strLstAdd(parseOptionList[option.id].valueList, value); + optionValue->valueList = strLstNew(); + strLstAdd(optionValue->valueList, value); } } } @@ -737,38 +832,37 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel) // Phase 3: parse config file unless --no-config passed // --------------------------------------------------------------------------------------------------------------------- // Load the configuration file(s) - String *configString = cfgFileLoad(parseOptionList, - STR(cfgDefOptionDefault(commandId, cfgOptionDefIdFromId(cfgOptConfig))), - STR(cfgDefOptionDefault(commandId, cfgOptionDefIdFromId(cfgOptConfigIncludePath))), - PGBACKREST_CONFIG_ORIG_PATH_FILE_STR); + String *configString = cfgFileLoad( + parseOptionList, STR(cfgDefOptionDefault(config->command, cfgOptConfig)), + STR(cfgDefOptionDefault(config->command, cfgOptConfigIncludePath)), PGBACKREST_CONFIG_ORIG_PATH_FILE_STR); if (configString != NULL) { - Ini *config = iniNew(); - iniParse(config, configString); + Ini *ini = iniNew(); + iniParse(ini, configString); // Get the stanza name String *stanza = NULL; - if (parseOptionList[cfgOptStanza].found) - stanza = strLstGet(parseOptionList[cfgOptStanza].valueList, 0); + if (parseOptionList[cfgOptStanza].indexList != NULL) + stanza = strLstGet(parseOptionList[cfgOptStanza].indexList[0].valueList, 0); // Build list of sections to search for options StringList *sectionList = strLstNew(); if (stanza != NULL) { - strLstAdd(sectionList, strNewFmt("%s:%s", strZ(stanza), cfgCommandName(cfgCommand()))); + strLstAdd(sectionList, strNewFmt("%s:%s", strZ(stanza), cfgCommandName(config->command))); strLstAdd(sectionList, stanza); } - strLstAdd(sectionList, strNewFmt(CFGDEF_SECTION_GLOBAL ":%s", cfgCommandName(cfgCommand()))); + strLstAdd(sectionList, strNewFmt(CFGDEF_SECTION_GLOBAL ":%s", cfgCommandName(config->command))); strLstAdd(sectionList, CFGDEF_SECTION_GLOBAL_STR); // Loop through sections to search for options for (unsigned int sectionIdx = 0; sectionIdx < strLstSize(sectionList); sectionIdx++) { String *section = strLstGet(sectionList, sectionIdx); - StringList *keyList = iniSectionKeyList(config, section); + StringList *keyList = iniSectionKeyList(ini, section); KeyValue *optionFound = kvNew(); // Loop through keys to search for options @@ -798,17 +892,15 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel) continue; } - ConfigDefineOption optionDefId = cfgOptionDefIdFromId(option.id); - // Warn if this option should be command-line only - if (cfgDefOptionSection(optionDefId) == cfgDefSectionCommandLine) + if (cfgDefOptionSection(option.id) == cfgDefSectionCommandLine) { LOG_WARN_FMT("configuration file contains command-line only option '%s'", strZ(key)); continue; } // Make sure this option does not appear in the same section with an alternate name - const Variant *optionFoundKey = VARINT(option.id); + const Variant *optionFoundKey = VARUINT64(option.id * CFG_OPTION_KEY_MAX + option.keyIdx); const Variant *optionFoundName = kvGet(optionFound, optionFoundKey); if (optionFoundName != NULL) @@ -821,7 +913,7 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel) kvPut(optionFound, optionFoundKey, VARSTR(key)); // Continue if the option is not valid for this command - if (!cfgDefOptionValid(commandId, optionDefId)) + if (!cfgDefOptionValid(config->command, option.id)) { // Warn if it is in a command section if (sectionIdx % 2 == 0) @@ -836,8 +928,7 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel) } // Continue if stanza option is in a global section - if (cfgDefOptionSection(optionDefId) == cfgDefSectionStanza && - strBeginsWithZ(section, CFGDEF_SECTION_GLOBAL)) + if (cfgDefOptionSection(option.id) == cfgDefSectionStanza && strBeginsWithZ(section, CFGDEF_SECTION_GLOBAL)) { LOG_WARN_FMT( "configuration file contains stanza-only option '%s' in global section '%s'", strZ(key), @@ -846,25 +937,31 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel) } // Continue if this option has already been found in another section or command-line/environment - if (parseOptionList[option.id].found) + ParseOptionValue *optionValue = parseOptionIdxValue(parseOptionList, option.id, option.keyIdx); + + if (optionValue->found) continue; - parseOptionList[option.id].found = true; - parseOptionList[option.id].source = cfgSourceConfig; + optionValue->found = true; + optionValue->source = cfgSourceConfig; // Process list - if (iniSectionKeyIsList(config, section, key)) + if (iniSectionKeyIsList(ini, section, key)) { // Error if the option cannot be specified multiple times - if (!cfgDefOptionMulti(optionDefId)) - THROW_FMT(OptionInvalidError, "option '%s' cannot be set multiple times", cfgOptionName(option.id)); + if (!cfgDefOptionMulti(option.id)) + { + THROW_FMT( + OptionInvalidError, "option '%s' cannot be set multiple times", + cfgOptionKeyIdxName(option.id, option.keyIdx)); + } - parseOptionList[option.id].valueList = iniGetList(config, section, key); + optionValue->valueList = iniGetList(ini, section, key); } else { // Get the option value - const String *value = iniGet(config, section, key); + const String *value = iniGet(ini, section, key); if (strSize(value) == 0) { @@ -873,304 +970,502 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel) strZ(key)); } - if (cfgDefOptionType(optionDefId) == cfgDefOptTypeBoolean) + if (cfgDefOptionType(option.id) == cfgDefOptTypeBoolean) { if (strEqZ(value, "n")) - parseOptionList[option.id].negate = true; + optionValue->negate = true; else if (!strEqZ(value, "y")) THROW_FMT(OptionInvalidValueError, "boolean option '%s' must be 'y' or 'n'", strZ(key)); } // Else add the string value else { - parseOptionList[option.id].valueList = strLstNew(); - strLstAdd(parseOptionList[option.id].valueList, value); + optionValue->valueList = strLstNew(); + strLstAdd(optionValue->valueList, value); } } } } } - // Phase 4: validate option definitions and load into configuration + // Phase 4: create the config and resolve indexed options for each group + // --------------------------------------------------------------------------------------------------------------------- + // Determine how many indexes are used in each group + bool groupIdxMap[CFG_OPTION_GROUP_TOTAL][CFG_OPTION_KEY_MAX] = {{0}}; + + for (unsigned int optionId = 0; optionId < CFG_OPTION_TOTAL; optionId++) + { + // Is the option valid for this command? + if (cfgDefOptionValid(config->command, optionId)) + { + config->option[optionId].valid = true; + } + else + { + // Error if the invalid option was explicitly set on the command-line + if (parseOptionList[optionId].indexList != NULL) + { + THROW_FMT( + OptionInvalidError, "option '%s' not valid for command '%s'", cfgDefOptionName(optionId), + cfgCommandName(config->command)); + } + + // Continue to the next option + continue; + } + + // If the option is in a group + if (cfgOptionGroup(optionId)) + { + unsigned int groupId = cfgOptionGroupId(optionId); + + config->optionGroup[groupId].valid = true; + + // Scan the option values to determine which indexes are in use. Store them in a map that will later be scanned + // to create a list of just the used indexes. + for (unsigned int optionKeyIdx = 0; optionKeyIdx < parseOptionList[optionId].indexListTotal; optionKeyIdx++) + { + if (parseOptionList[optionId].indexList[optionKeyIdx].found && + !parseOptionList[optionId].indexList[optionKeyIdx].reset) + { + if (!groupIdxMap[groupId][optionKeyIdx]) + { + config->optionGroup[groupId].indexTotal++; + groupIdxMap[groupId][optionKeyIdx] = true; + } + } + } + } + } + + // Write the indexes into the group in order + for (unsigned int groupId = 0; groupId < CFG_OPTION_GROUP_TOTAL; groupId++) + { + // Skip the group if it is not valid + if (!config->optionGroup[groupId].valid) + continue; + + // If no values were found in any index then use index 0 since all valid groups must have at least one index. This + // may lead to an error unless all options in the group have defaults but that will be resolved later. + if (config->optionGroup[groupId].indexTotal == 0) + { + config->optionGroup[groupId].indexTotal = 1; + } + // Else write the key to index map for the group. This allows translation from keys to indexes and vice versa. + else + { + unsigned int optionIdxMax = 0; + unsigned int optionKeyIdx = 0; + + // ??? For the pg group, key 1 is required to maintain compatibilty with older versions. Before removing this + // constraint the pg group remap to key 1 for remotes will need to be dealt with in the protocol/helper module. + if (groupId == cfgOptGrpPg) + { + optionKeyIdx = 1; + optionIdxMax = 1; + } + + for (; optionKeyIdx < CFG_OPTION_KEY_MAX; optionKeyIdx++) + { + if (groupIdxMap[groupId][optionKeyIdx]) + { + config->optionGroup[groupId].indexMap[optionIdxMax] = optionKeyIdx; + optionIdxMax++; + } + } + } + } + + // Phase 5: validate option definitions and load into configuration // --------------------------------------------------------------------------------------------------------------------- for (unsigned int optionOrderIdx = 0; optionOrderIdx < CFG_OPTION_TOTAL; optionOrderIdx++) { // Validate options based on the option resolve order. This allows resolving all options in a single pass. ConfigOption optionId = optionResolveOrder[optionOrderIdx]; - // Get the option data parsed from the command-line - ParseOption *parseOption = &parseOptionList[optionId]; - - // Get the option definition id -- will be used to look up option rules - ConfigDefineOption optionDefId = cfgOptionDefIdFromId(optionId); - ConfigDefineOptionType optionDefType = cfgDefOptionType(optionDefId); - - // Error if the option is not valid for this command - if (parseOption->found && !cfgDefOptionValid(commandId, optionDefId)) - { - THROW_FMT( - OptionInvalidError, "option '%s' not valid for command '%s'", cfgOptionName(optionId), - cfgCommandName(cfgCommand())); - } - - // Is the option valid for this command? If not, there is nothing more to do. - cfgOptionValidSet(optionId, cfgDefOptionValid(commandId, optionDefId)); - - if (!cfgOptionValid(optionId)) + // Skip this option if it is not valid + if (!config->option[optionId].valid) continue; - // Is the value set for this option? - bool optionSet = - parseOption->found && (optionDefType == cfgDefOptTypeBoolean || !parseOption->negate) && - !parseOption->reset; + // Determine the option index total. For options that are not indexed the index total is 1. + bool optionGroup = cfgOptionGroup(optionId); + unsigned int optionGroupId = optionGroup ? cfgOptionGroupId(optionId) : UINT_MAX; + unsigned int optionListIndexTotal = optionGroup ? config->optionGroup[optionGroupId].indexTotal : 1; - // Set negate flag - cfgOptionNegateSet(optionId, parseOption->negate); - - // Set reset flag - cfgOptionResetSet(optionId, parseOption->reset); - - // Check option dependencies - bool dependResolved = true; - - if (cfgDefOptionDepend(commandId, optionDefId)) + MEM_CONTEXT_BEGIN(config->memContext) { - ConfigOption dependOptionId = - cfgOptionIdFromDefId(cfgDefOptionDependOption(commandId, optionDefId), cfgOptionIndex(optionId)); - ConfigDefineOption dependOptionDefId = cfgOptionDefIdFromId(dependOptionId); - ConfigDefineOptionType dependOptionDefType = cfgDefOptionType(dependOptionDefId); - - // Get the depend option value - const Variant *dependValue = cfgOption(dependOptionId); - - if (dependValue != NULL) - { - if (dependOptionDefType == cfgDefOptTypeBoolean) - { - if (cfgOptionBool(dependOptionId)) - dependValue = OPTION_VALUE_1; - else - dependValue = OPTION_VALUE_0; - } - } - - // Can't resolve if the depend option value is null - if (dependValue == NULL) - { - dependResolved = false; - - // If depend not resolved and option value is set on the command-line then error. See unresolved list - // depend below for a detailed explanation. - if (optionSet && parseOption->source == cfgSourceParam) - { - THROW_FMT( - OptionInvalidError, "option '%s' not valid without option '%s'", cfgOptionName(optionId), - cfgOptionName(dependOptionId)); - } - } - // If a depend list exists, make sure the value is in the list - else if (cfgDefOptionDependValueTotal(commandId, optionDefId) > 0) - { - dependResolved = cfgDefOptionDependValueValid(commandId, optionDefId, strZ(varStr(dependValue))); - - // If depend not resolved and option value is set on the command-line then error. It's OK to have - // unresolved options in the config file because they may be there for another command. For instance, - // spool-path is only loaded for the archive-push command when archive-async=y, and the presence of - // spool-path in the config file should not cause an error here, it will just end up null. - if (!dependResolved && optionSet && parseOption->source == cfgSourceParam) - { - // Get the depend option name - const String *dependOptionName = STR(cfgOptionName(dependOptionId)); - - // Build the list of possible depend values - StringList *dependValueList = strLstNew(); - - for (unsigned int listIdx = 0; - listIdx < cfgDefOptionDependValueTotal(commandId, optionDefId); listIdx++) - { - const char *dependValue = cfgDefOptionDependValue(commandId, optionDefId, listIdx); - - // Build list based on depend option type - if (dependOptionDefType == cfgDefOptTypeBoolean) - { - // Boolean outputs depend option name as no-* when false - if (strcmp(dependValue, "0") == 0) - dependOptionName = strNewFmt("no-%s", cfgOptionName(dependOptionId)); - } - else - { - ASSERT(dependOptionDefType == cfgDefOptTypePath || dependOptionDefType == cfgDefOptTypeString); - strLstAdd(dependValueList, strNewFmt("'%s'", dependValue)); - } - } - - // Build the error string - const String *errorValue = EMPTY_STR; - - if (strLstSize(dependValueList) == 1) - errorValue = strNewFmt(" = %s", strZ(strLstGet(dependValueList, 0))); - else if (strLstSize(dependValueList) > 1) - errorValue = strNewFmt(" in (%s)", strZ(strLstJoin(dependValueList, ", "))); - - // Throw the error - THROW( - OptionInvalidError, - strZ( - strNewFmt( - "option '%s' not valid without option '%s'%s", cfgOptionName(optionId), - strZ(dependOptionName), strZ(errorValue)))); - } - } + config->option[optionId].index = memNew(sizeof(ConfigOptionValue) * optionListIndexTotal); } + MEM_CONTEXT_END(); - // Is the option resolved? - if (dependResolved) + // Loop through the option indexes + ConfigDefineOptionType optionDefType = cfgDefOptionType(optionId); + + for (unsigned int optionListIdx = 0; optionListIdx < optionListIndexTotal; optionListIdx++) { - // Is the option set? - if (optionSet) + // Get the key index by looking it up in the group or by defaulting to 0 for ungrouped options + unsigned optionKeyIdx = optionGroup ? config->optionGroup[optionGroupId].indexMap[optionListIdx] : 0; + + // Get the parsed value using the key index. Provide a default structure when the value was not found. + ParseOptionValue *parseOptionValue = optionKeyIdx < parseOptionList[optionId].indexListTotal ? + &parseOptionList[optionId].indexList[optionKeyIdx] : &(ParseOptionValue){0}; + + // Get the location where the value will be stored in the configuration + ConfigOptionValue *configOptionValue = &config->option[optionId].index[optionListIdx]; + + // Is the value set for this option? + bool optionSet = + parseOptionValue->found && (optionDefType == cfgDefOptTypeBoolean || !parseOptionValue->negate) && + !parseOptionValue->reset; + + // Initialize option value and set negate and reset flag + *configOptionValue = (ConfigOptionValue){.negate = parseOptionValue->negate, .reset = parseOptionValue->reset}; + + // Check option dependencies + bool dependResolved = true; + + if (cfgDefOptionDepend(config->command, optionId)) { - if (optionDefType == cfgDefOptTypeBoolean) - { - cfgOptionSet(optionId, parseOption->source, VARBOOL(!parseOption->negate)); - } - else if (optionDefType == cfgDefOptTypeHash) - { - Variant *value = varNewKv(kvNew()); - KeyValue *keyValue = varKv(value); + ConfigOption dependOptionId = cfgDefOptionDependOption(config->command, optionId); + ConfigDefineOptionType dependOptionDefType = cfgDefOptionType(dependOptionId); - for (unsigned int listIdx = 0; listIdx < strLstSize(parseOption->valueList); listIdx++) + // Get the depend option value + const Variant *dependValue = config->option[dependOptionId].index[optionListIdx].value; + + if (dependValue != NULL) + { + if (dependOptionDefType == cfgDefOptTypeBoolean) { - const char *pair = strZ(strLstGet(parseOption->valueList, listIdx)); - const char *equal = strchr(pair, '='); - - if (equal == NULL) - { - THROW_FMT( - OptionInvalidError, "key/value '%s' not valid for '%s' option", - strZ(strLstGet(parseOption->valueList, listIdx)), cfgOptionName(optionId)); - } - - kvPut(keyValue, VARSTR(strNewN(pair, (size_t)(equal - pair))), VARSTRZ(equal + 1)); + if (varBool(dependValue)) + dependValue = OPTION_VALUE_1; + else + dependValue = OPTION_VALUE_0; } - - cfgOptionSet(optionId, parseOption->source, value); } - else if (optionDefType == cfgDefOptTypeList) + + // Can't resolve if the depend option value is null + if (dependValue == NULL) { - cfgOptionSet(optionId, parseOption->source, varNewVarLst(varLstNewStrLst(parseOption->valueList))); - } - else - { - String *value = strLstGet(parseOption->valueList, 0); + dependResolved = false; - // If a numeric type check that the value is valid - if (optionDefType == cfgDefOptTypeInteger || optionDefType == cfgDefOptTypeFloat || - optionDefType == cfgDefOptTypeSize) - { - double valueDbl = 0; - - // Check that the value can be converted - TRY_BEGIN() - { - if (optionDefType == cfgDefOptTypeInteger) - { - valueDbl = (double)varInt64Force(VARSTR(value)); - } - else if (optionDefType == cfgDefOptTypeSize) - { - convertToByte(&value, &valueDbl); - } - else - valueDbl = varDblForce(VARSTR(value)); - } - CATCH_ANY() - { - THROW_FMT( - OptionInvalidValueError, "'%s' is not valid for '%s' option", strZ(value), - cfgOptionName(optionId)); - } - TRY_END(); - - // Check value range - if (cfgDefOptionAllowRange(commandId, optionDefId) && - (valueDbl < cfgDefOptionAllowRangeMin(commandId, optionDefId) || - valueDbl > cfgDefOptionAllowRangeMax(commandId, optionDefId))) - { - THROW_FMT( - OptionInvalidValueError, "'%s' is out of range for '%s' option", strZ(value), - cfgOptionName(optionId)); - } - } - // Else if path make sure it is valid - else if (optionDefType == cfgDefOptTypePath) - { - // Make sure it is long enough to be a path - if (strSize(value) == 0) - { - THROW_FMT( - OptionInvalidValueError, "'%s' must be >= 1 character for '%s' option", strZ(value), - cfgOptionName(optionId)); - } - - // Make sure it starts with / - if (!strBeginsWithZ(value, "/")) - { - THROW_FMT( - OptionInvalidValueError, "'%s' must begin with / for '%s' option", strZ(value), - cfgOptionName(optionId)); - } - - // Make sure there are no occurrences of // - if (strstr(strZ(value), "//") != NULL) - { - THROW_FMT( - OptionInvalidValueError, "'%s' cannot contain // for '%s' option", strZ(value), - cfgOptionName(optionId)); - } - - // If the path ends with a / we'll strip it off (unless the value is just /) - if (strEndsWithZ(value, "/") && strSize(value) != 1) - strTrunc(value, (int)strSize(value) - 1); - } - - // If the option has an allow list then check it - if (cfgDefOptionAllowList(commandId, optionDefId) && - !cfgDefOptionAllowListValueValid(commandId, optionDefId, strZ(value))) + // If depend not resolved and option value is set on the command-line then error. See unresolved list + // depend below for a detailed explanation. + if (optionSet && parseOptionValue->source == cfgSourceParam) { THROW_FMT( - OptionInvalidValueError, "'%s' is not allowed for '%s' option", strZ(value), - cfgOptionName(optionId)); + OptionInvalidError, "option '%s' not valid without option '%s'", + cfgOptionKeyIdxName(optionId, optionKeyIdx), cfgOptionKeyIdxName(dependOptionId, optionKeyIdx)); } + } + // If a depend list exists, make sure the value is in the list + else if (cfgDefOptionDependValueTotal(config->command, optionId) > 0) + { + dependResolved = cfgDefOptionDependValueValid(config->command, optionId, strZ(varStr(dependValue))); - cfgOptionSet(optionId, parseOption->source, VARSTR(value)); + // If depend not resolved and option value is set on the command-line then error. It's OK to have + // unresolved options in the config file because they may be there for another command. For instance, + // spool-path is only loaded for the archive-push command when archive-async=y, and the presence of + // spool-path in the config file should not cause an error here, it will just end up null. + if (!dependResolved && optionSet && parseOptionValue->source == cfgSourceParam) + { + // Get the depend option name + const String *dependOptionName = STR(cfgOptionKeyIdxName(dependOptionId, optionKeyIdx)); + + // Build the list of possible depend values + StringList *dependValueList = strLstNew(); + + for (unsigned int listIdx = 0; + listIdx < cfgDefOptionDependValueTotal(config->command, optionId); listIdx++) + { + const char *dependValue = cfgDefOptionDependValue(config->command, optionId, listIdx); + + // Build list based on depend option type + if (dependOptionDefType == cfgDefOptTypeBoolean) + { + // Boolean outputs depend option name as no-* when false + if (strcmp(dependValue, ZERO_Z) == 0) + { + dependOptionName = + strNewFmt("no-%s", cfgOptionKeyIdxName(dependOptionId, optionKeyIdx)); + } + } + else + { + ASSERT(dependOptionDefType == cfgDefOptTypePath || dependOptionDefType == cfgDefOptTypeString); + strLstAdd(dependValueList, strNewFmt("'%s'", dependValue)); + } + } + + // Build the error string + const String *errorValue = EMPTY_STR; + + if (strLstSize(dependValueList) == 1) + errorValue = strNewFmt(" = %s", strZ(strLstGet(dependValueList, 0))); + else if (strLstSize(dependValueList) > 1) + errorValue = strNewFmt(" in (%s)", strZ(strLstJoin(dependValueList, ", "))); + + // Throw the error + THROW( + OptionInvalidError, + strZ( + strNewFmt( + "option '%s' not valid without option '%s'%s", + cfgOptionKeyIdxName(optionId, optionKeyIdx), strZ(dependOptionName), + strZ(errorValue)))); + } } } - else if (parseOption->negate) - cfgOptionSet(optionId, parseOption->source, NULL); - // Else try to set a default - else + + // Is the option resolved? + if (dependResolved) { - // Get the default value for this option - const char *value = cfgDefOptionDefault(commandId, optionDefId); - - if (value != NULL) - cfgOptionSet(optionId, cfgSourceDefault, VARSTRZ(value)); - else if (cfgOptionIndex(optionId) == 0 && cfgDefOptionRequired(commandId, optionDefId) && - !cfgCommandHelp()) + // Is the option set? + if (optionSet) { - const char *hint = ""; + configOptionValue->source = parseOptionValue->source; - if (cfgDefOptionSection(optionDefId) == cfgDefSectionStanza) - hint = "\nHINT: does this stanza exist?"; + if (optionDefType == cfgDefOptTypeBoolean) + { + configOptionValue->value = !parseOptionValue->negate ? BOOL_TRUE_VAR : BOOL_FALSE_VAR; + } + else if (optionDefType == cfgDefOptTypeHash) + { + Variant *value = NULL; - THROW_FMT( - OptionRequiredError, "%s command requires option: %s%s", cfgCommandName(cfgCommand()), - cfgOptionName(optionId), hint); + MEM_CONTEXT_BEGIN(config->memContext) + { + value = varNewKv(kvNew()); + } + MEM_CONTEXT_END(); + + KeyValue *keyValue = varKv(value); + + for (unsigned int listIdx = 0; listIdx < strLstSize(parseOptionValue->valueList); listIdx++) + { + const char *pair = strZ(strLstGet(parseOptionValue->valueList, listIdx)); + const char *equal = strchr(pair, '='); + + if (equal == NULL) + { + THROW_FMT( + OptionInvalidError, "key/value '%s' not valid for '%s' option", + strZ(strLstGet(parseOptionValue->valueList, listIdx)), + cfgOptionKeyIdxName(optionId, optionKeyIdx)); + } + + kvPut(keyValue, VARSTR(strNewN(pair, (size_t)(equal - pair))), VARSTRZ(equal + 1)); + } + + configOptionValue->value = value; + } + else if (optionDefType == cfgDefOptTypeList) + { + MEM_CONTEXT_BEGIN(config->memContext) + { + configOptionValue->value = varNewVarLst(varLstNewStrLst(parseOptionValue->valueList)); + } + MEM_CONTEXT_END(); + } + else + { + String *value = strLstGet(parseOptionValue->valueList, 0); + + // If a numeric type check that the value is valid + if (optionDefType == cfgDefOptTypeInteger || optionDefType == cfgDefOptTypeFloat || + optionDefType == cfgDefOptTypeSize) + { + double valueDbl = 0; + + // Check that the value can be converted + TRY_BEGIN() + { + if (optionDefType == cfgDefOptTypeInteger) + { + MEM_CONTEXT_BEGIN(config->memContext) + { + configOptionValue->value = varNewInt64(cvtZToInt64(strZ(value))); + } + MEM_CONTEXT_END(); + + valueDbl = (double)varInt64(configOptionValue->value); + } + else if (optionDefType == cfgDefOptTypeSize) + { + convertToByte(&value, &valueDbl); + + MEM_CONTEXT_BEGIN(config->memContext) + { + configOptionValue->value = varNewInt64((int64_t)valueDbl); + } + MEM_CONTEXT_END(); + } + else + { + MEM_CONTEXT_BEGIN(config->memContext) + { + configOptionValue->value = varNewDbl(cvtZToDouble(strZ(value))); + } + MEM_CONTEXT_END(); + + valueDbl = varDbl(configOptionValue->value); + } + } + CATCH_ANY() + { + THROW_FMT( + OptionInvalidValueError, "'%s' is not valid for '%s' option", strZ(value), + cfgOptionKeyIdxName(optionId, optionKeyIdx)); + } + TRY_END(); + + // Check value range + if (cfgDefOptionAllowRange(config->command, optionId) && + (valueDbl < cfgDefOptionAllowRangeMin(config->command, optionId) || + valueDbl > cfgDefOptionAllowRangeMax(config->command, optionId))) + { + THROW_FMT( + OptionInvalidValueError, "'%s' is out of range for '%s' option", strZ(value), + cfgOptionKeyIdxName(optionId, optionKeyIdx)); + } + } + // Else if path make sure it is valid + else + { + // Make sure it is long enough to be a path + if (strSize(value) == 0) + { + THROW_FMT( + OptionInvalidValueError, "'%s' must be >= 1 character for '%s' option", strZ(value), + cfgOptionKeyIdxName(optionId, optionKeyIdx)); + } + + if (optionDefType == cfgDefOptTypePath) + { + // Make sure it starts with / + if (!strBeginsWithZ(value, "/")) + { + THROW_FMT( + OptionInvalidValueError, "'%s' must begin with / for '%s' option", strZ(value), + cfgOptionKeyIdxName(optionId, optionKeyIdx)); + } + + // Make sure there are no occurrences of // + if (strstr(strZ(value), "//") != NULL) + { + THROW_FMT( + OptionInvalidValueError, "'%s' cannot contain // for '%s' option", strZ(value), + cfgOptionKeyIdxName(optionId, optionKeyIdx)); + } + + // If the path ends with a / we'll strip it off (unless the value is just /) + if (strEndsWithZ(value, "/") && strSize(value) != 1) + strTrunc(value, (int)strSize(value) - 1); + } + + MEM_CONTEXT_BEGIN(config->memContext) + { + configOptionValue->value = varNewStr(value); + } + MEM_CONTEXT_END(); + } + + // If the option has an allow list then check it + if (cfgDefOptionAllowList(config->command, optionId) && + !cfgDefOptionAllowListValueValid(config->command, optionId, strZ(value))) + { + THROW_FMT( + OptionInvalidValueError, "'%s' is not allowed for '%s' option", strZ(value), + cfgOptionKeyIdxName(optionId, optionKeyIdx)); + } + } + } + else if (parseOptionValue->negate) + configOptionValue->source = parseOptionValue->source; + // Else try to set a default + else + { + // Get the default value for this option + const char *value = cfgDefOptionDefault(config->command, optionId); + + // If the option has a default + if (value != NULL) + { + MEM_CONTEXT_BEGIN(config->memContext) + { + // This would typically be a switch but since not all cases are covered it would require a + // separate function which does not seem worth it. The eventual plan is to have all the defaults + // represented as constants so they can be assigned directly without creating variants. + if (optionDefType == cfgDefOptTypeBoolean) + configOptionValue->value = strcmp(value, ONE_Z) == 0 ? BOOL_TRUE_VAR : BOOL_FALSE_VAR; + else if (optionDefType == cfgDefOptTypeFloat) + configOptionValue->value = varNewDbl(cvtZToDouble(value)); + else if (optionDefType == cfgDefOptTypeInteger || optionDefType == cfgDefOptTypeSize) + configOptionValue->value = varNewInt64(cvtZToInt64(value)); + else + { + ASSERT(optionDefType == cfgDefOptTypePath || optionDefType == cfgDefOptTypeString); + + configOptionValue->value = varNewStrZ(value); + } + } + MEM_CONTEXT_END(); + } + // Else error if option is required and help was not requested + else if (cfgDefOptionRequired(config->command, optionId) && !config->help) + { + const char *hint = ""; + + if (cfgDefOptionSection(optionId) == cfgDefSectionStanza) + hint = "\nHINT: does this stanza exist?"; + + THROW_FMT( + OptionRequiredError, "%s command requires option: %s%s", cfgCommandName(config->command), + cfgOptionKeyIdxName(optionId, optionKeyIdx), hint); + } } } } } } + + // Initialize config + cfgInit(config); + + // Set option group default index. The first index in the group is automatically set unless the group option, e.g. repo, is + // set. For now the group default options are hard-coded but they could be dynamic. An assert has been added to make sure + // the code breaks if a new group is added. + for (unsigned int groupId = 0; groupId < CFG_OPTION_GROUP_TOTAL; groupId++) + { + ASSERT(groupId == cfgOptGrpPg || groupId == cfgOptGrpRepo); + + // Get the group default option + unsigned int defaultOptionId = groupId == cfgOptGrpPg ? cfgOptPg : cfgOptRepo; + + // Does the group default option exist? + if (cfgOptionTest(defaultOptionId)) + { + // Search for the key + unsigned int optionKeyIdx = cfgOptionUInt(defaultOptionId) - 1; + unsigned int index = 0; + + for (; index < cfgOptionGroupIdxTotal(groupId); index++) + { + if (config->optionGroup[groupId].indexMap[index] == optionKeyIdx) + break; + } + + // Error if the key was not found + if (index == cfgOptionGroupIdxTotal(groupId)) + { + THROW_FMT( + OptionInvalidValueError, "key '%u' is not valid for '%s' option", cfgOptionUInt(defaultOptionId), + cfgOptionName(defaultOptionId)); + } + + // Set the default + config->optionGroup[groupId].indexDefault = index; + } + } } MEM_CONTEXT_TEMP_END(); diff --git a/src/config/parse.h b/src/config/parse.h index 6e6fc3b67..2b58a92c5 100644 --- a/src/config/parse.h +++ b/src/config/parse.h @@ -17,6 +17,7 @@ typedef struct CfgParseOptionResult { bool found; // Was the option found? ConfigOption id; // Option ID + unsigned int keyIdx; // Option key index, i.e. option key - 1 bool negate; // Was the option negated? bool reset; // Was the option reset? bool deprecated; // Is the option deprecated? diff --git a/src/config/protocol.c b/src/config/protocol.c index 3ae25966d..d1ef2bb43 100644 --- a/src/config/protocol.c +++ b/src/config/protocol.c @@ -7,7 +7,7 @@ Configuration Protocol Handler #include "common/io/io.h" #include "common/log.h" #include "common/memContext.h" -#include "config/config.h" +#include "config/config.intern.h" #include "config/parse.h" #include "config/protocol.h" @@ -42,7 +42,7 @@ configProtocol(const String *command, const VariantList *paramList, ProtocolServ CfgParseOptionResult option = cfgParseOption(varStr(varLstGet(paramList, optionIdx))); CHECK(option.found); - varLstAdd(optionList, varDup(cfgOption(option.id))); + varLstAdd(optionList, varDup(cfgOptionIdx(option.id, cfgOptionKeyToIdx(option.id, option.keyIdx + 1)))); } protocolServerResponse(server, varNewVarLst(optionList)); diff --git a/src/db/helper.c b/src/db/helper.c index 2ca2341f1..2346f56c0 100644 --- a/src/db/helper.c +++ b/src/db/helper.c @@ -30,8 +30,8 @@ dbGetIdx(unsigned int pgIdx) { result = dbNew( pgClientNew( - cfgOptionStrNull(cfgOptPgSocketPath + pgIdx), cfgOptionUInt(cfgOptPgPort + pgIdx), PG_DB_POSTGRES_STR, - cfgOptionStrNull(cfgOptPgUser + pgIdx), (TimeMSec)(cfgOptionDbl(cfgOptDbTimeout) * MSEC_PER_SEC)), + cfgOptionIdxStrNull(cfgOptPgSocketPath, pgIdx), cfgOptionIdxUInt(cfgOptPgPort, pgIdx), PG_DB_POSTGRES_STR, + cfgOptionIdxStrNull(cfgOptPgUser, pgIdx), (TimeMSec)(cfgOptionDbl(cfgOptDbTimeout) * MSEC_PER_SEC)), NULL, applicationName); } else @@ -65,62 +65,61 @@ dbGet(bool primaryOnly, bool primaryRequired, bool standbyRequired) // Loop through to look for primary and standby (if required) for (unsigned int pgIdx = 0; pgIdx < cfgOptionGroupIdxTotal(cfgOptGrpPg); pgIdx++) { - if (cfgOptionGroupIdxTest(cfgOptGrpPg, pgIdx)) - { - Db *db = NULL; - bool standby = false; + Db *db = NULL; + bool standby = false; + TRY_BEGIN() + { + db = dbGetIdx(pgIdx); + + // This needs to be nested because db can be reset to NULL on an error in the outer try but we need the pointer + // to be able to free it. TRY_BEGIN() { - db = dbGetIdx(pgIdx); - - // This needs to be nested because db can be reset to NULL on an error in the outer try but we need the pointer - // to be able to free it. - TRY_BEGIN() - { - dbOpen(db); - standby = dbIsStandby(db); - } - CATCH_ANY() - { - dbFree(db); - RETHROW(); - } - TRY_END(); + dbOpen(db); + standby = dbIsStandby(db); } CATCH_ANY() { - LOG_WARN_FMT("unable to check pg-%u: [%s] %s", pgIdx + 1, errorTypeName(errorType()), errorMessage()); - db = NULL; + dbFree(db); + RETHROW(); } TRY_END(); + } + CATCH_ANY() + { + LOG_WARN_FMT( + "unable to check pg-%u: [%s] %s", cfgOptionGroupIdxToKey(cfgOptGrpPg, pgIdx), errorTypeName(errorType()), + errorMessage()); + db = NULL; + } + TRY_END(); - // Was the connection successful - if (db != NULL) + // Was the connection successful + if (db != NULL) + { + // Is this cluster a standby + if (standby) { - // Is this cluster a standby - if (standby) + // If a standby has not already been found then assign it + if (result.standby == NULL && !primaryOnly) { - // If a standby has not already been found then assign it - if (result.standby == NULL && !primaryOnly) - { - result.standbyIdx = pgIdx; - result.standby = db; - } - // Else close the connection since we don't need it - else - dbFree(db); + result.standbyIdx = pgIdx; + result.standby = db; } - // Else is a primary + // Else close the connection since we don't need it else - { - // Error if more than one primary was found - if (result.primary != NULL) - THROW(DbConnectError, "more than one primary cluster found"); + dbFree(db); + } + // Else is a primary + else + { + // Error if more than one primary was found + if (result.primary != NULL) + THROW(DbConnectError, "more than one primary cluster found"); - result.primaryIdx = pgIdx; - result.primary = db; - } + result.primaryIdx = pgIdx; + result.primary = db; } } } diff --git a/src/protocol/helper.c b/src/protocol/helper.c index 9c49aae7c..ec3c021e4 100644 --- a/src/protocol/helper.c +++ b/src/protocol/helper.c @@ -9,7 +9,7 @@ Protocol Helper #include "common/debug.h" #include "common/exec.h" #include "common/memContext.h" -#include "config/config.h" +#include "config/config.intern.h" #include "config/define.h" #include "config/exec.h" #include "config/protocol.h" @@ -70,10 +70,13 @@ protocolHelperInit(void) /**********************************************************************************************************************************/ bool -repoIsLocal(void) +repoIsLocal(unsigned int repoIdx) { - FUNCTION_TEST_VOID(); - FUNCTION_TEST_RETURN(!cfgOptionTest(cfgOptRepoHost)); + FUNCTION_LOG_BEGIN(logLevelDebug); + FUNCTION_LOG_PARAM(UINT, repoIdx); + FUNCTION_LOG_END(); + + FUNCTION_LOG_RETURN(BOOL, !cfgOptionIdxTest(cfgOptRepoHost, repoIdx)); } /**********************************************************************************************************************************/ @@ -82,7 +85,7 @@ repoIsLocalVerify(void) { FUNCTION_TEST_VOID(); - if (!repoIsLocal()) + if (!repoIsLocal(cfgOptionGroupIdxDefault(cfgOptGrpRepo))) THROW_FMT(HostInvalidError, "%s command must be run on the repository host", cfgCommandName(cfgCommand())); FUNCTION_TEST_RETURN_VOID(); @@ -96,7 +99,7 @@ pgIsLocal(unsigned int pgIdx) FUNCTION_LOG_PARAM(UINT, pgIdx); FUNCTION_LOG_END(); - FUNCTION_LOG_RETURN(BOOL, !cfgOptionTest(cfgOptPgHost + pgIdx)); + FUNCTION_LOG_RETURN(BOOL, !cfgOptionIdxTest(cfgOptPgHost, pgIdx)); } /**********************************************************************************************************************************/ @@ -105,7 +108,7 @@ pgIsLocalVerify(void) { FUNCTION_TEST_VOID(); - if (!pgIsLocal(0)) + if (!pgIsLocal(cfgOptionGroupIdxDefault(cfgOptGrpPg))) THROW_FMT(HostInvalidError, "%s command must be run on the " PG_NAME " host", cfgCommandName(cfgCommand())); FUNCTION_TEST_RETURN_VOID(); @@ -133,8 +136,13 @@ protocolLocalParam(ProtocolStorageType protocolStorageType, unsigned int hostIdx // Add the process id -- used when more than one process will be called kvPut(optionReplace, VARSTR(CFGOPT_PROCESS_STR), VARUINT(processId)); - // Add the host id - kvPut(optionReplace, VARSTR(CFGOPT_HOST_ID_STR), VARUINT(hostIdx + 1)); + // Add the group default id + kvPut( + optionReplace, + VARSTRZ(cfgOptionName(protocolStorageType == protocolStorageTypeRepo ? cfgOptRepo : cfgOptPg)), + VARUINT( + cfgOptionGroupIdxToKey( + protocolStorageType == protocolStorageTypeRepo ? cfgOptGrpRepo : cfgOptGrpPg, hostIdx))); // Add the remote type kvPut(optionReplace, VARSTR(CFGOPT_REMOTE_TYPE_STR), VARSTR(protocolStorageTypeStr(protocolStorageType))); @@ -295,111 +303,122 @@ protocolRemoteParam(ProtocolStorageType protocolStorageType, unsigned int hostId strLstAddZ(result, "PasswordAuthentication=no"); // Append port if specified - ConfigOption optHostPort = isRepo ? cfgOptRepoHostPort : cfgOptPgHostPort + hostIdx; + ConfigOption optHostPort = isRepo ? cfgOptRepoHostPort : cfgOptPgHostPort; - if (cfgOptionTest(optHostPort)) + if (cfgOptionIdxTest(optHostPort, hostIdx)) { strLstAddZ(result, "-p"); - strLstAdd(result, strNewFmt("%u", cfgOptionUInt(optHostPort))); + strLstAdd(result, strNewFmt("%u", cfgOptionIdxUInt(optHostPort, hostIdx))); } // Append user/host strLstAdd( result, strNewFmt( - "%s@%s", strZ(cfgOptionStr(isRepo ? cfgOptRepoHostUser : cfgOptPgHostUser + hostIdx)), - strZ(cfgOptionStr(isRepo ? cfgOptRepoHost : cfgOptPgHost + hostIdx)))); + "%s@%s", strZ(cfgOptionIdxStr(isRepo ? cfgOptRepoHostUser : cfgOptPgHostUser, hostIdx)), + strZ(cfgOptionIdxStr(isRepo ? cfgOptRepoHost : cfgOptPgHost, hostIdx)))); // Option replacements KeyValue *optionReplace = kvNew(); // Replace config options with the host versions - unsigned int optConfig = isRepo ? cfgOptRepoHostConfig : cfgOptPgHostConfig + hostIdx; + unsigned int optConfig = isRepo ? cfgOptRepoHostConfig : cfgOptPgHostConfig; - kvPut(optionReplace, VARSTR(CFGOPT_CONFIG_STR), cfgOptionSource(optConfig) != cfgSourceDefault ? cfgOption(optConfig) : NULL); + kvPut( + optionReplace, VARSTR(CFGOPT_CONFIG_STR), + cfgOptionIdxSource(optConfig, hostIdx) != cfgSourceDefault ? VARSTR(cfgOptionIdxStr(optConfig, hostIdx)) : NULL); - unsigned int optConfigIncludePath = isRepo ? cfgOptRepoHostConfigIncludePath : cfgOptPgHostConfigIncludePath + hostIdx; + unsigned int optConfigIncludePath = isRepo ? cfgOptRepoHostConfigIncludePath : cfgOptPgHostConfigIncludePath; kvPut( optionReplace, VARSTR(CFGOPT_CONFIG_INCLUDE_PATH_STR), - cfgOptionSource(optConfigIncludePath) != cfgSourceDefault ? cfgOption(optConfigIncludePath) : NULL); + cfgOptionIdxSource(optConfigIncludePath, hostIdx) != cfgSourceDefault ? + VARSTR(cfgOptionIdxStr(optConfigIncludePath, hostIdx)) : NULL); - unsigned int optConfigPath = isRepo ? cfgOptRepoHostConfigPath : cfgOptPgHostConfigPath + hostIdx; + unsigned int optConfigPath = isRepo ? cfgOptRepoHostConfigPath : cfgOptPgHostConfigPath; kvPut( optionReplace, VARSTR(CFGOPT_CONFIG_PATH_STR), - cfgOptionSource(optConfigPath) != cfgSourceDefault ? cfgOption(optConfigPath) : NULL); + cfgOptionIdxSource(optConfigPath, hostIdx) != cfgSourceDefault ? VARSTR(cfgOptionIdxStr(optConfigPath, hostIdx)) : NULL); // Update/remove repo/pg options that are sent to the remote - const String *repoHostPrefix = STR(cfgDefOptionName(cfgDefOptRepoHost)); - const String *repoPrefix = strNewFmt("%s-", PROTOCOL_REMOTE_TYPE_REPO); - const String *pgHostPrefix = STR(cfgDefOptionName(cfgDefOptPgHost)); - const String *pgPrefix = strNewFmt("%s-", PROTOCOL_REMOTE_TYPE_PG); + const String *repoHostPrefix = STR(cfgDefOptionName(cfgOptRepoHost)); + const String *pgHostPrefix = STR(cfgDefOptionName(cfgOptPgHost)); for (ConfigOption optionId = 0; optionId < CFG_OPTION_TOTAL; optionId++) { - ConfigDefineOption optionDefId = cfgOptionDefIdFromId(optionId); - const String *optionDefName = STR(cfgDefOptionName(optionDefId)); - bool remove = false; + // Skip options that are not part of a group + if (!cfgOptionGroup(optionId)) + continue; - // Remove repo host options that are not needed on the remote. The remote is not expecting to see host settings and it - // could get confused about the locality of the repo, i.e. local or remote. - if (strBeginsWith(optionDefName, repoHostPrefix)) + const String *optionDefName = STR(cfgDefOptionName(optionId)); + unsigned int groupId = cfgOptionGroupId(optionId); + bool remove = false; + bool skipHostZero = false; + + // Remove repo host options that are not needed on the remote. The remote is not expecting to see host settings so it could + // get confused about the locality of the repo, i.e. local or remote. Also remove repo options when the remote type is pg + // since they won't be used. + if (groupId == cfgOptGrpRepo) { - remove = true; + remove = protocolStorageType == protocolStorageTypePg || strBeginsWith(optionDefName, repoHostPrefix); } - // Remove repo options when the remote type is pg since they won't be used - else if (strBeginsWith(optionDefName, repoPrefix)) - { - if (protocolStorageType == protocolStorageTypePg) - remove = true; - } - // Remove pg host options that are not needed on the remote. The remote is not expecting to see host settings and it could - // get confused about the locality of pg, i.e. local or remote. - else if (strBeginsWith(optionDefName, pgHostPrefix)) - { - remove = true; - } - else if (strBeginsWith(optionDefName, pgPrefix)) + // Remove pg host options that are not needed on the remote + else { + ASSERT(groupId == cfgOptGrpPg); + // Remove unrequired/defaulted pg options when the remote type is repo since they won't be used if (protocolStorageType == protocolStorageTypeRepo) { - remove = !cfgDefOptionRequired(cfgCommand(), optionDefId) || cfgDefOptionDefault(cfgCommand(), optionDefId) != NULL; + remove = !cfgDefOptionRequired(cfgCommand(), optionId) || cfgDefOptionDefault(cfgCommand(), optionId) != NULL; } - // Else move/remove pg options with index > 0 since they won't be used - else if (cfgOptionIndex(optionId) > 0) + // The remote is not expecting to see host settings so it could get confused about the locality of pg, i.e. local or + // remote. + else if (strBeginsWith(optionDefName, pgHostPrefix)) { - // If the option index matches the host-id then this is a pg option that the remote needs. Since the remote expects - // to find pg options in index 0, copy the option to index 0. - if (cfgOptionIndex(optionId) == hostIdx) + remove = true; + } + // Move pg options to host index 0 (key 1) so they will be in the default index on the remote host + else + { + if (hostIdx != 0) { kvPut( - optionReplace, VARSTRZ(cfgOptionName(optionId - hostIdx)), - cfgOptionSource(optionId) != cfgSourceDefault ? cfgOption(optionId) : NULL); + optionReplace, VARSTRZ(cfgOptionIdxName(optionId, 0)), + cfgOptionIdxSource(optionId, hostIdx) != cfgSourceDefault ? cfgOptionIdx(optionId, hostIdx) : NULL); } - // Remove pg options that are not needed on the remote. The remote is only going to look at index 0 so the options - // in higher indexes will not be used and just add clutter which makes debugging harder. remove = true; + skipHostZero = true; } } // Remove options that have been marked for removal if they are not already null or invalid. This is more efficient because // cfgExecParam() won't have to search through as large a list looking for overrides. - if (remove && cfgOptionTest(optionId)) - kvPut(optionReplace, VARSTRZ(cfgOptionName(optionId)), NULL); + if (remove) + { + // Loop through option indexes + for (unsigned int optionIdx = 0; optionIdx < cfgOptionIdxTotal(optionId); optionIdx++) + { + if (cfgOptionIdxTest(optionId, optionIdx) && !(skipHostZero && optionIdx == 0)) + kvPut(optionReplace, VARSTRZ(cfgOptionIdxName(optionId, optionIdx)), NULL); + } + } } // Set local so host settings configured on the remote will not accidentally be picked up kvPut( optionReplace, protocolStorageType == protocolStorageTypeRepo ? - VARSTRZ(cfgOptionName(cfgOptRepoLocal)) : VARSTRZ(cfgOptionName(cfgOptPgLocal)), + VARSTRZ(cfgOptionIdxName(cfgOptRepoLocal, hostIdx)) : VARSTRZ(cfgOptionKeyIdxName(cfgOptPgLocal, 0)), BOOL_TRUE_VAR); - // Don't pass host-id to the remote. The host will always be in index 0. - kvPut(optionReplace, VARSTR(CFGOPT_HOST_ID_STR), NULL); + // Set default to make it explicit which host will be used on the remote + kvPut( + optionReplace, + VARSTRZ(cfgOptionName(protocolStorageType == protocolStorageTypeRepo ? cfgOptRepo : cfgOptPg)), + VARUINT(protocolStorageType == protocolStorageTypeRepo ? cfgOptionGroupIdxToKey(cfgOptGrpRepo, hostIdx) : 1)); // Add the process id if not set. This means that the remote is being started from the main process and should always get a // process id of 0. @@ -436,7 +455,7 @@ protocolRemoteParam(ProtocolStorageType protocolStorageType, unsigned int hostId kvPut(optionReplace, VARSTR(CFGOPT_REMOTE_TYPE_STR), VARSTR(protocolStorageTypeStr(protocolStorageType))); StringList *commandExec = cfgExecParam(cfgCommand(), cfgCmdRoleRemote, optionReplace, false, true); - strLstInsert(commandExec, 0, cfgOptionStr(isRepo ? cfgOptRepoHostCmd : cfgOptPgHostCmd + hostIdx)); + strLstInsert(commandExec, 0, cfgOptionIdxStr(isRepo ? cfgOptRepoHostCmd : cfgOptPgHostCmd, hostIdx)); strLstAdd(result, strLstJoin(commandExec, " ")); FUNCTION_LOG_RETURN(STRING_LIST, result); @@ -464,9 +483,9 @@ protocolRemoteGet(ProtocolStorageType protocolStorageType, unsigned int hostIdx) // The number of remotes allowed is the greater of allowed repo or pg configs + 1 (0 is reserved for connections from // the main process). Since these are static and only one will be true it presents a problem for coverage. We think // that pg remotes will always be greater but we'll protect that assumption with an assertion. - ASSERT(cfgDefOptionIndexTotal(cfgDefOptPgPath) >= cfgDefOptionIndexTotal(cfgDefOptRepoPath)); + ASSERT(cfgDefOptionIndexTotal(cfgOptPgPath) >= cfgDefOptionIndexTotal(cfgOptRepoPath)); - protocolHelper.clientRemoteSize = cfgDefOptionIndexTotal(cfgDefOptPgPath) + 1; + protocolHelper.clientRemoteSize = cfgDefOptionIndexTotal(cfgOptPgPath) + 1; protocolHelper.clientRemote = memNew(protocolHelper.clientRemoteSize * sizeof(ProtocolHelperClient)); for (unsigned int clientIdx = 0; clientIdx < protocolHelper.clientRemoteSize; clientIdx++) @@ -492,18 +511,18 @@ protocolRemoteGet(ProtocolStorageType protocolStorageType, unsigned int hostIdx) { MEM_CONTEXT_BEGIN(protocolHelper.memContext) { - unsigned int optHost = isRepo ? cfgOptRepoHost : cfgOptPgHost + hostIdx; + unsigned int optHost = isRepo ? cfgOptRepoHost : cfgOptPgHost; // Execute the protocol command protocolHelperClient->exec = execNew( cfgOptionStr(cfgOptCmdSsh), protocolRemoteParam(protocolStorageType, hostIdx), - strNewFmt(PROTOCOL_SERVICE_REMOTE "-%u process on '%s'", processId, strZ(cfgOptionStr(optHost))), + strNewFmt(PROTOCOL_SERVICE_REMOTE "-%u process on '%s'", processId, strZ(cfgOptionIdxStr(optHost, hostIdx))), (TimeMSec)(cfgOptionDbl(cfgOptProtocolTimeout) * 1000)); execOpen(protocolHelperClient->exec); // Create protocol object protocolHelperClient->client = protocolClientNew( - strNewFmt(PROTOCOL_SERVICE_REMOTE "-%u protocol on '%s'", processId, strZ(cfgOptionStr(optHost))), + strNewFmt(PROTOCOL_SERVICE_REMOTE "-%u protocol on '%s'", processId, strZ(cfgOptionIdxStr(optHost, hostIdx))), PROTOCOL_SERVICE_REMOTE_STR, execIoRead(protocolHelperClient->exec), execIoWrite(protocolHelperClient->exec)); // Get cipher options from the remote if none are locally configured diff --git a/src/protocol/helper.h b/src/protocol/helper.h index 810a1c2d6..1bdb345eb 100644 --- a/src/protocol/helper.h +++ b/src/protocol/helper.h @@ -54,7 +54,7 @@ bool pgIsLocal(unsigned int pgIdx); void pgIsLocalVerify(void); // Is the repository local? -bool repoIsLocal(void); +bool repoIsLocal(unsigned int repoIdx); // Error if the repository is not local void repoIsLocalVerify(void); diff --git a/src/storage/helper.c b/src/storage/helper.c index 0e7cc4547..092bbb5db 100644 --- a/src/storage/helper.c +++ b/src/storage/helper.c @@ -48,8 +48,8 @@ static struct StorageHelper Storage *storageLocalWrite; // Local write storage Storage **storagePg; // PostgreSQL read-only storage Storage **storagePgWrite; // PostgreSQL write storage - Storage *storageRepo; // Repository read-only storage - Storage *storageRepoWrite; // Repository write storage + Storage **storageRepo; // Repository read-only storage + Storage **storageRepoWrite; // Repository write storage Storage *storageSpool; // Spool read-only storage Storage *storageSpoolWrite; // Spool write storage @@ -183,7 +183,7 @@ storagePgGet(unsigned int pgIdx, bool write) // Use Posix storage else { - result = storagePosixNewP(cfgOptionStr(cfgOptPgPath + pgIdx), .write = write); + result = storagePosixNewP(cfgOptionIdxStr(cfgOptPgPath, pgIdx), .write = write); } FUNCTION_TEST_RETURN(result); @@ -204,7 +204,7 @@ storagePgIdx(unsigned int pgIdx) MEM_CONTEXT_BEGIN(storageHelper.memContext) { if (storageHelper.storagePg == NULL) - storageHelper.storagePg = memNewPtrArray(cfgDefOptionIndexTotal(cfgDefOptPgPath)); + storageHelper.storagePg = memNewPtrArray(cfgOptionGroupIdxTotal(cfgOptGrpPg)); storageHelper.storagePg[pgIdx] = storagePgGet(pgIdx, false); } @@ -218,7 +218,7 @@ const Storage * storagePg(void) { FUNCTION_TEST_VOID(); - FUNCTION_TEST_RETURN(storagePgIdx(cfgOptionTest(cfgOptHostId) ? cfgOptionUInt(cfgOptHostId) - 1 : 0)); + FUNCTION_TEST_RETURN(storagePgIdx(cfgOptionGroupIdxDefault(cfgOptGrpPg))); } const Storage * @@ -239,7 +239,7 @@ storagePgIdxWrite(unsigned int pgIdx) MEM_CONTEXT_BEGIN(storageHelper.memContext) { if (storageHelper.storagePgWrite == NULL) - storageHelper.storagePgWrite = memNewPtrArray(cfgDefOptionIndexTotal(cfgDefOptPgPath)); + storageHelper.storagePgWrite = memNewPtrArray(cfgOptionGroupIdxTotal(cfgOptGrpPg)); storageHelper.storagePgWrite[pgIdx] = storagePgGet(pgIdx, true); } @@ -253,7 +253,7 @@ const Storage * storagePgWrite(void) { FUNCTION_TEST_VOID(); - FUNCTION_TEST_RETURN(storagePgIdxWrite(cfgOptionTest(cfgOptHostId) ? cfgOptionUInt(cfgOptHostId) - 1 : 0)); + FUNCTION_TEST_RETURN(storagePgIdxWrite(cfgOptionGroupIdxDefault(cfgOptGrpPg))); } /*********************************************************************************************************************************** @@ -333,83 +333,95 @@ storageRepoPathExpression(const String *expression, const String *path) Get the repo storage ***********************************************************************************************************************************/ static Storage * -storageRepoGet(const String *type, bool write) +storageRepoGet(unsigned int repoIdx, bool write) { FUNCTION_TEST_BEGIN(); - FUNCTION_TEST_PARAM(STRING, type); + FUNCTION_TEST_PARAM(UINT, repoIdx); FUNCTION_TEST_PARAM(BOOL, write); FUNCTION_TEST_END(); - ASSERT(type != NULL); - Storage *result = NULL; // Use remote storage - if (!repoIsLocal()) + if (!repoIsLocal(repoIdx)) { result = storageRemoteNew( STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, write, storageRepoPathExpression, - protocolRemoteGet(protocolStorageTypeRepo, 0), cfgOptionUInt(cfgOptCompressLevelNetwork)); + protocolRemoteGet(protocolStorageTypeRepo, repoIdx), cfgOptionIdxUInt(cfgOptCompressLevelNetwork, repoIdx)); } // Use Azure storage - else if (strEqZ(type, STORAGE_AZURE_TYPE)) - { - result = storageAzureNew( - cfgOptionStr(cfgOptRepoPath), write, storageRepoPathExpression, cfgOptionStr(cfgOptRepoAzureContainer), - cfgOptionStr(cfgOptRepoAzureAccount), - strEqZ(cfgOptionStr(cfgOptRepoAzureKeyType), STORAGE_AZURE_KEY_TYPE_SHARED) ? - storageAzureKeyTypeShared : storageAzureKeyTypeSas, - cfgOptionStr(cfgOptRepoAzureKey), STORAGE_AZURE_BLOCKSIZE_MIN, cfgOptionStrNull(cfgOptRepoAzureHost), - cfgOptionStr(cfgOptRepoAzureEndpoint), cfgOptionUInt(cfgOptRepoAzurePort), ioTimeoutMs(), - cfgOptionBool(cfgOptRepoAzureVerifyTls), cfgOptionStrNull(cfgOptRepoAzureCaFile), - cfgOptionStrNull(cfgOptRepoAzureCaPath)); - } - // Use CIFS storage - else if (strEqZ(type, STORAGE_CIFS_TYPE)) - { - result = storageCifsNew( - cfgOptionStr(cfgOptRepoPath), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, write, storageRepoPathExpression); - } - // Use Posix storage - else if (strEqZ(type, STORAGE_POSIX_TYPE)) - { - result = storagePosixNewP( - cfgOptionStr(cfgOptRepoPath), .write = write, .pathExpressionFunction = storageRepoPathExpression); - } - // Use S3 storage - else if (strEqZ(type, STORAGE_S3_TYPE)) - { - // Set the default port - unsigned int port = cfgOptionUInt(cfgOptRepoS3Port); - - // Extract port from the endpoint and host if it is present - const String *endPoint = cfgOptionHostPort(cfgOptRepoS3Endpoint, &port); - const String *host = cfgOptionHostPort(cfgOptRepoS3Host, &port); - - // If the port option was set explicitly then use it in preference to appended ports - if (cfgOptionSource(cfgOptRepoS3Port) != cfgSourceDefault) - port = cfgOptionUInt(cfgOptRepoS3Port); - - result = storageS3New( - cfgOptionStr(cfgOptRepoPath), write, storageRepoPathExpression, cfgOptionStr(cfgOptRepoS3Bucket), endPoint, - strEqZ(cfgOptionStr(cfgOptRepoS3UriStyle), STORAGE_S3_URI_STYLE_HOST) ? storageS3UriStyleHost : storageS3UriStylePath, - cfgOptionStr(cfgOptRepoS3Region), - strEqZ(cfgOptionStr(cfgOptRepoS3KeyType), STORAGE_S3_KEY_TYPE_SHARED) ? storageS3KeyTypeShared : storageS3KeyTypeAuto, - cfgOptionStrNull(cfgOptRepoS3Key), cfgOptionStrNull(cfgOptRepoS3KeySecret), cfgOptionStrNull(cfgOptRepoS3Token), - cfgOptionStrNull(cfgOptRepoS3Role), STORAGE_S3_PARTSIZE_MIN, host, port, ioTimeoutMs(), - cfgOptionBool(cfgOptRepoS3VerifyTls), cfgOptionStrNull(cfgOptRepoS3CaFile), cfgOptionStrNull(cfgOptRepoS3CaPath)); - } else - THROW_FMT(AssertError, "invalid storage type '%s'", strZ(type)); + { + const String *type = cfgOptionIdxStr(cfgOptRepoType, repoIdx); + + if (strEqZ(type, STORAGE_AZURE_TYPE)) + { + result = storageAzureNew( + cfgOptionIdxStr(cfgOptRepoPath, repoIdx), write, storageRepoPathExpression, + cfgOptionIdxStr(cfgOptRepoAzureContainer, repoIdx), cfgOptionIdxStr(cfgOptRepoAzureAccount, repoIdx), + strEqZ(cfgOptionIdxStr(cfgOptRepoAzureKeyType, repoIdx), STORAGE_AZURE_KEY_TYPE_SHARED) ? + storageAzureKeyTypeShared : storageAzureKeyTypeSas, + cfgOptionIdxStr(cfgOptRepoAzureKey, repoIdx), STORAGE_AZURE_BLOCKSIZE_MIN, + cfgOptionIdxStrNull(cfgOptRepoAzureHost, repoIdx), cfgOptionIdxStr(cfgOptRepoAzureEndpoint, repoIdx), + cfgOptionIdxUInt(cfgOptRepoAzurePort, repoIdx), ioTimeoutMs(), cfgOptionIdxBool(cfgOptRepoAzureVerifyTls, repoIdx), + cfgOptionIdxStrNull(cfgOptRepoAzureCaFile, repoIdx), + cfgOptionIdxStrNull(cfgOptRepoAzureCaPath, repoIdx)); + } + // Use CIFS storage + else if (strEqZ(type, STORAGE_CIFS_TYPE)) + { + result = storageCifsNew( + cfgOptionIdxStr(cfgOptRepoPath, repoIdx), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, write, + storageRepoPathExpression); + } + // Use Posix storage + else if (strEqZ(type, STORAGE_POSIX_TYPE)) + { + result = storagePosixNewP( + cfgOptionIdxStr(cfgOptRepoPath, repoIdx), .write = write, .pathExpressionFunction = storageRepoPathExpression); + } + // Use S3 storage + else + { + // Storage must be S3 + CHECK(strEqZ(type, STORAGE_S3_TYPE)); + + // Set the default port + unsigned int port = cfgOptionIdxUInt(cfgOptRepoS3Port, repoIdx); + + // Extract port from the endpoint and host if it is present + const String *endPoint = cfgOptionIdxHostPort(cfgOptRepoS3Endpoint, repoIdx, &port); + const String *host = cfgOptionIdxHostPort(cfgOptRepoS3Host, repoIdx, &port); + + // If the port option was set explicitly then use it in preference to appended ports + if (cfgOptionIdxSource(cfgOptRepoS3Port, repoIdx) != cfgSourceDefault) + port = cfgOptionIdxUInt(cfgOptRepoS3Port, repoIdx); + + result = storageS3New( + cfgOptionIdxStr(cfgOptRepoPath, repoIdx), write, storageRepoPathExpression, + cfgOptionIdxStr(cfgOptRepoS3Bucket, repoIdx), endPoint, + strEqZ(cfgOptionIdxStr(cfgOptRepoS3UriStyle, repoIdx), STORAGE_S3_URI_STYLE_HOST) ? + storageS3UriStyleHost : storageS3UriStylePath, + cfgOptionIdxStr(cfgOptRepoS3Region, repoIdx), + strEqZ(cfgOptionIdxStr(cfgOptRepoS3KeyType, repoIdx), STORAGE_S3_KEY_TYPE_SHARED) ? + storageS3KeyTypeShared : storageS3KeyTypeAuto, + cfgOptionIdxStrNull(cfgOptRepoS3Key, repoIdx), cfgOptionIdxStrNull(cfgOptRepoS3KeySecret, repoIdx), + cfgOptionIdxStrNull(cfgOptRepoS3Token, repoIdx), cfgOptionIdxStrNull(cfgOptRepoS3Role, repoIdx), + STORAGE_S3_PARTSIZE_MIN, host, port, ioTimeoutMs(), cfgOptionIdxBool(cfgOptRepoS3VerifyTls, repoIdx), + cfgOptionIdxStrNull(cfgOptRepoS3CaFile, repoIdx), cfgOptionIdxStrNull(cfgOptRepoS3CaPath, repoIdx)); + } + } FUNCTION_TEST_RETURN(result); } /**********************************************************************************************************************************/ const Storage * -storageRepo(void) +storageRepoIdx(unsigned int repoIdx) { - FUNCTION_TEST_VOID(); + FUNCTION_TEST_BEGIN(); + FUNCTION_TEST_PARAM(UINT, repoIdx); + FUNCTION_TEST_END(); if (storageHelper.storageRepo == NULL) { @@ -419,18 +431,36 @@ storageRepo(void) MEM_CONTEXT_BEGIN(storageHelper.memContext) { - storageHelper.storageRepo = storageRepoGet(cfgOptionStr(cfgOptRepoType), false); + storageHelper.storageRepo = memNewPtrArray(cfgOptionGroupIdxTotal(cfgOptGrpRepo)); } MEM_CONTEXT_END(); } - FUNCTION_TEST_RETURN(storageHelper.storageRepo); + if (storageHelper.storageRepo[repoIdx] == NULL) + { + MEM_CONTEXT_BEGIN(storageHelper.memContext) + { + storageHelper.storageRepo[repoIdx] = storageRepoGet(repoIdx, false); + } + MEM_CONTEXT_END(); + } + + FUNCTION_TEST_RETURN(storageHelper.storageRepo[repoIdx]); } const Storage * -storageRepoWrite(void) +storageRepo(void) { FUNCTION_TEST_VOID(); + FUNCTION_TEST_RETURN(storageRepoIdx(cfgOptionGroupIdxDefault(cfgOptGrpRepo))); +} + +const Storage * +storageRepoIdxWrite(unsigned int repoIdx) +{ + FUNCTION_TEST_BEGIN(); + FUNCTION_TEST_PARAM(UINT, repoIdx); + FUNCTION_TEST_END(); // Writes not allowed in dry-run mode if (!storageHelper.dryRunInit || storageHelper.dryRun) @@ -444,12 +474,28 @@ storageRepoWrite(void) MEM_CONTEXT_BEGIN(storageHelper.memContext) { - storageHelper.storageRepoWrite = storageRepoGet(cfgOptionStr(cfgOptRepoType), true); + storageHelper.storageRepoWrite = memNewPtrArray(cfgOptionGroupIdxTotal(cfgOptGrpRepo)); } MEM_CONTEXT_END(); } - FUNCTION_TEST_RETURN(storageHelper.storageRepoWrite); + if (storageHelper.storageRepoWrite[repoIdx] == NULL) + { + MEM_CONTEXT_BEGIN(storageHelper.memContext) + { + storageHelper.storageRepoWrite[repoIdx] = storageRepoGet(repoIdx, true); + } + MEM_CONTEXT_END(); + } + + FUNCTION_TEST_RETURN(storageHelper.storageRepoWrite[repoIdx]); +} + +const Storage * +storageRepoWrite(void) +{ + FUNCTION_TEST_VOID(); + FUNCTION_TEST_RETURN(storageRepoIdxWrite(cfgOptionGroupIdxDefault(cfgOptGrpRepo))); } /*********************************************************************************************************************************** diff --git a/src/storage/helper.h b/src/storage/helper.h index 67313610a..10485fb14 100644 --- a/src/storage/helper.h +++ b/src/storage/helper.h @@ -41,11 +41,15 @@ const Storage *storageLocalWrite(void); const Storage *storagePgIdx(unsigned int pgIdx); const Storage *storagePgIdxWrite(unsigned int pgIdx); -// PostgreSQL storage default (calculated from host-id, when set, or the first cfgOptGrpPg index) +// PostgreSQL storage default (calculated from the pg option, when set, or the first cfgOptGrpPg index) const Storage *storagePg(void); const Storage *storagePgWrite(void); -// Repository storage +// Repository storage by cfgOptGrpRepo index +const Storage *storageRepoIdx(unsigned int repoIdx); +const Storage *storageRepoIdxWrite(unsigned int repoIdx); + +// Repository storage default (calculated from the repo option, when set, or the first cfgOptGrpPg index) const Storage *storageRepo(void); const Storage *storageRepoWrite(void); diff --git a/test/define.yaml b/test/define.yaml index 263fad38f..084e83433 100644 --- a/test/define.yaml +++ b/test/define.yaml @@ -365,18 +365,11 @@ unit: config/define.auto: noCode # ---------------------------------------------------------------------------------------------------------------------------- - - name: config - total: 4 + - name: parse + total: 5 coverage: config/config: full - config/config.auto: noCode - - # ---------------------------------------------------------------------------------------------------------------------------- - - name: parse - total: 4 - - coverage: config/parse: full config/parse.auto: noCode diff --git a/test/src/common/harnessConfig.c b/test/src/common/harnessConfig.c index dc0d35b89..78a55afec 100644 --- a/test/src/common/harnessConfig.c +++ b/test/src/common/harnessConfig.c @@ -10,6 +10,7 @@ Harness for Loading Test Configurations #include "common/harnessLog.h" #include "common/harnessTest.h" +#include "config/config.intern.h" #include "config/define.h" #include "config/load.h" #include "config/parse.h" @@ -58,11 +59,11 @@ harnessCfgLoadRole(ConfigCommand commandId, ConfigCommandRole commandRoleId, con StringList *argList = strLstDup(argListParam); // Set log path if valid - if (cfgDefOptionValid(commandId, cfgDefOptLogPath)) + if (cfgDefOptionValid(commandId, cfgOptLogPath)) strLstInsert(argList, 0, strNewFmt("--" CFGOPT_LOG_PATH "=%s", testDataPath())); // Set lock path if valid - if (cfgDefOptionValid(commandId, cfgDefOptLockPath)) + if (cfgDefOptionValid(commandId, cfgOptLockPath)) strLstInsert(argList, 0, strNewFmt("--" CFGOPT_LOCK_PATH "=%s/lock", testDataPath())); // Insert the command so it does not interfere with parameters @@ -138,7 +139,7 @@ hrnCfgArgRawZ(StringList *argList, ConfigOption optionId, const char *value) void hrnCfgArgKeyRawZ(StringList *argList, ConfigOption optionId, unsigned optionKey, const char *value) { - strLstAdd(argList, strNewFmt("--%s=%s", cfgOptionName(optionId + optionKey - 1), value)); + strLstAdd(argList, strNewFmt("--%s=%s", cfgOptionKeyIdxName(optionId, optionKey - 1), value)); } void @@ -150,7 +151,7 @@ hrnCfgArgRawBool(StringList *argList, ConfigOption optionId, bool value) void hrnCfgArgKeyRawBool(StringList *argList, ConfigOption optionId, unsigned optionKey, bool value) { - strLstAdd(argList, strNewFmt("--%s%s", value ? "" : "no-", cfgOptionName(optionId + optionKey - 1))); + strLstAdd(argList, strNewFmt("--%s%s", value ? "" : "no-", cfgOptionKeyIdxName(optionId, optionKey - 1))); } void @@ -162,7 +163,7 @@ hrnCfgArgRawNegate(StringList *argList, ConfigOption optionId) void hrnCfgArgKeyRawNegate(StringList *argList, ConfigOption optionId, unsigned optionKey) { - strLstAdd(argList, strNewFmt("--no-%s", cfgOptionName(optionId + optionKey - 1))); + strLstAdd(argList, strNewFmt("--no-%s", cfgOptionKeyIdxName(optionId, optionKey - 1))); } void @@ -174,7 +175,7 @@ hrnCfgArgRawReset(StringList *argList, ConfigOption optionId) void hrnCfgArgKeyRawReset(StringList *argList, ConfigOption optionId, unsigned optionKey) { - strLstAdd(argList, strNewFmt("--reset-%s", cfgOptionName(optionId + optionKey - 1))); + strLstAdd(argList, strNewFmt("--reset-%s", cfgOptionKeyIdxName(optionId, optionKey - 1))); } /**********************************************************************************************************************************/ @@ -199,7 +200,7 @@ hrnCfgEnvRawZ(ConfigOption optionId, const char *value) void hrnCfgEnvKeyRawZ(ConfigOption optionId, unsigned optionKey, const char *value) { - setenv(strZ(strNewFmt(HRN_PGBACKREST_ENV "%s", cfgOptionName(optionId + optionKey - 1))), value, true); + setenv(strZ(strNewFmt(HRN_PGBACKREST_ENV "%s", cfgOptionKeyIdxName(optionId, optionKey - 1))), value, true); } void @@ -211,5 +212,5 @@ hrnCfgEnvRemoveRaw(ConfigOption optionId) void hrnCfgEnvKeyRemoveRaw(ConfigOption optionId, unsigned optionKey) { - unsetenv(strZ(strNewFmt(HRN_PGBACKREST_ENV "%s", cfgOptionName(optionId + optionKey - 1)))); + unsetenv(strZ(strNewFmt(HRN_PGBACKREST_ENV "%s", cfgOptionKeyIdxName(optionId, optionKey - 1)))); } diff --git a/test/src/module/command/localTest.c b/test/src/module/command/localTest.c index 558d622e2..b9cb2a068 100644 --- a/test/src/module/command/localTest.c +++ b/test/src/module/command/localTest.c @@ -35,7 +35,7 @@ testRun(void) hrnCfgArgRawZ(argList, cfgOptPgPath, "/path/to/pg"); strLstAddZ(argList, "--process=1"); strLstAddZ(argList, "--" CFGOPT_REMOTE_TYPE "=" PROTOCOL_REMOTE_TYPE_REPO); - strLstAddZ(argList, "--host-id=1"); + hrnCfgArgRawZ(argList, cfgOptPg, "1"); harnessCfgLoadRole(cfgCmdArchiveGet, cfgCmdRoleLocal, argList); cmdLocal(HARNESS_FORK_CHILD_READ(), HARNESS_FORK_CHILD_WRITE()); diff --git a/test/src/module/config/configTest.c b/test/src/module/config/configTest.c deleted file mode 100644 index 91d6ac4e3..000000000 --- a/test/src/module/config/configTest.c +++ /dev/null @@ -1,294 +0,0 @@ -/*********************************************************************************************************************************** -Test Configuration Commands and Options -***********************************************************************************************************************************/ - -/*********************************************************************************************************************************** -Test run -***********************************************************************************************************************************/ -void -testRun(void) -{ - FUNCTION_HARNESS_VOID(); - - // Static tests against known values -- these may break as options change so will need to be kept up to date. The tests have - // generally been selected to favor values that are not expected to change but adjustments are welcome as long as the type of - // test is not drastically changed. - // ***************************************************************************************************************************** - if (testBegin("check known values")) - { - TEST_ERROR(cfgCommandId(BOGUS_STR, true), AssertError, "invalid command 'BOGUS'"); - TEST_RESULT_INT(cfgCommandId(BOGUS_STR, false), cfgCmdNone, "command none id from bogus"); - TEST_RESULT_INT(cfgCommandId("archive-push", true), cfgCmdArchivePush, "command id from name"); - - TEST_RESULT_Z(cfgCommandName(cfgCmdBackup), "backup", "command name from id"); - - TEST_RESULT_INT(cfgOptionDefIdFromId(cfgOptPgHost + 6), cfgDefOptPgHost, "option id to def id"); - - TEST_ERROR( - cfgOptionIdFromDefId(999999, 6), AssertError, - "assertion 'optionId != CFG_OPTION_TOTAL' failed"); - TEST_ERROR( - cfgOptionIdFromDefId(0, 999999), AssertError, - "assertion 'index < cfgDefOptionIndexTotal(optionDefId)' failed"); - TEST_RESULT_INT(cfgOptionIdFromDefId(cfgDefOptPgHost, 6), cfgOptPgHost + 6, "option def id to id"); - - TEST_ERROR(cfgOptionIndex(CFG_OPTION_TOTAL), AssertError, "assertion 'optionId < CFG_OPTION_TOTAL' failed"); - TEST_RESULT_INT(cfgOptionIndex(cfgOptPgHostCmd + 6), 6, "option index"); - TEST_RESULT_INT(cfgOptionIndex(cfgOptCompressLevel), 0, "option index"); - - TEST_RESULT_Z(cfgOptionName(cfgOptBackupStandby), "backup-standby", "option id from name"); - } - - // ***************************************************************************************************************************** - if (testBegin("configuration")) - { - TEST_RESULT_VOID(cfgInit(), "config init"); - - // ------------------------------------------------------------------------------------------------------------------------- - TEST_RESULT_INT(cfgCommand(), cfgCmdNone, "command begins as none"); - TEST_RESULT_VOID(cfgCommandSet(cfgCmdBackup, cfgCmdRoleDefault), "command set to backup"); - TEST_RESULT_INT(cfgCommand(), cfgCmdBackup, "command is backup"); - TEST_RESULT_STR_Z(cfgCommandRoleName(), "backup", "command:role is backup"); - - // ------------------------------------------------------------------------------------------------------------------------- - TEST_RESULT_VOID(cfgCommandSet(cfgCmdBackup, cfgCmdRoleLocal), "command set to backup:local"); - TEST_RESULT_STR_Z(cfgCommandRoleName(), "backup:local", "command:role is backup:local"); - TEST_RESULT_INT(cfgCommandInternal(cfgCmdBackup), false, "backup is external"); - TEST_RESULT_INT(cfgLogLevelDefault(), logLevelInfo, "default log level is info"); - TEST_RESULT_BOOL(cfgLogFile(), true, "log file is on"); - TEST_RESULT_BOOL(cfgLockRequired(), false, "lock is not required"); - TEST_RESULT_BOOL(cfgLockRemoteRequired(), true, "remote lock is required"); - TEST_RESULT_INT(cfgLockType(), lockTypeBackup, "lock is type backup"); - TEST_RESULT_BOOL(cfgParameterAllowed(), false, "parameters not allowed"); - - TEST_RESULT_VOID(cfgCommandSet(cfgCmdInfo, cfgCmdRoleDefault), "command set to info"); - TEST_RESULT_INT(cfgLogLevelDefault(), logLevelDebug, "default log level is debug"); - TEST_RESULT_BOOL(cfgLogFile(), false, "log file is off"); - TEST_RESULT_BOOL(cfgLockRequired(), false, "lock is not required"); - TEST_RESULT_BOOL(cfgLockRemoteRequired(), false, "remote lock is not required"); - TEST_RESULT_INT(cfgLockType(), lockTypeNone, "lock is type none"); - - TEST_RESULT_VOID(cfgCommandSet(cfgCmdStanzaCreate, cfgCmdRoleDefault), "command set to stanza-create"); - TEST_RESULT_BOOL(cfgLockRequired(), true, "lock is required"); - TEST_RESULT_INT(cfgLockType(), lockTypeAll, "lock is type all"); - - TEST_RESULT_VOID(cfgCommandSet(cfgCmdArchiveGet, cfgCmdRoleAsync), "command set to archive-get:async"); - TEST_RESULT_BOOL(cfgLockRequired(), true, "lock is required"); - TEST_RESULT_BOOL(cfgLogFile(), true, "log file is on"); - - TEST_RESULT_VOID(cfgCommandSet(cfgCmdInfo, cfgCmdRoleDefault), "command set to info"); - - cfgOptionSet(cfgOptLogLevelFile, cfgSourceParam, VARSTRDEF("info")); - cfgOptionValidSet(cfgOptLogLevelFile, true); - - TEST_RESULT_BOOL(cfgLogFile(), true, "log file is on"); - - // ------------------------------------------------------------------------------------------------------------------------- - TEST_TITLE("command roles"); - - TEST_ERROR(cfgCommandRoleEnum(strNew(BOGUS_STR)), CommandInvalidError, "invalid command role 'BOGUS'"); - TEST_RESULT_UINT(cfgCommandRoleEnum(NULL), cfgCmdRoleDefault, "command default role enum"); - TEST_RESULT_UINT(cfgCommandRoleEnum(strNew("async")), cfgCmdRoleAsync, "command async role enum"); - TEST_RESULT_UINT(cfgCommandRoleEnum(strNew("local")), cfgCmdRoleLocal, "command local role enum"); - TEST_RESULT_UINT(cfgCommandRoleEnum(strNew("remote")), cfgCmdRoleRemote, "command remote role enum"); - - TEST_RESULT_STR(cfgCommandRoleStr(cfgCmdRoleDefault), NULL, "command default role str"); - TEST_RESULT_STR_Z(cfgCommandRoleStr(cfgCmdRoleAsync), "async", "command async role str"); - TEST_RESULT_STR_Z(cfgCommandRoleStr(cfgCmdRoleLocal), "local", "command local role str"); - TEST_RESULT_STR_Z(cfgCommandRoleStr(cfgCmdRoleRemote), "remote", "command remote role str"); - - // ------------------------------------------------------------------------------------------------------------------------- - TEST_RESULT_BOOL(cfgCommandHelp(), false, "command help defaults to false"); - TEST_RESULT_VOID(cfgCommandHelpSet(true), "set command help"); - TEST_RESULT_BOOL(cfgCommandHelp(), true, "command help is set"); - - // ------------------------------------------------------------------------------------------------------------------------- - StringList *param = strLstNew(); - strLstAddZ(param, "param"); - - TEST_RESULT_INT(strLstSize(cfgCommandParam()), 0, "command param list defaults to empty"); - TEST_RESULT_VOID(cfgCommandParamSet(param), "set command param list"); - TEST_RESULT_INT(strLstSize(cfgCommandParam()), 1, "command param list is set"); - - // ------------------------------------------------------------------------------------------------------------------------- - TEST_RESULT_STR(cfgExe(), NULL, "exe defaults to null"); - TEST_RESULT_VOID(cfgExeSet(strNew("/path/to/exe")), "set exe"); - TEST_RESULT_Z(strZ(cfgExe()), "/path/to/exe", "exe is set"); - - // ------------------------------------------------------------------------------------------------------------------------- - TEST_RESULT_BOOL(cfgOptionNegate(cfgOptConfig), false, "negate defaults to false"); - TEST_RESULT_VOID(cfgOptionNegateSet(cfgOptConfig, true), "set negate"); - TEST_RESULT_BOOL(cfgOptionNegate(cfgOptConfig), true, "negate is set"); - - // ------------------------------------------------------------------------------------------------------------------------- - TEST_RESULT_BOOL(cfgOptionReset(cfgOptConfig), false, "reset defaults to false"); - TEST_RESULT_VOID(cfgOptionResetSet(cfgOptConfig, true), "set reset"); - TEST_RESULT_BOOL(cfgOptionReset(cfgOptConfig), true, "reset is set"); - - // ------------------------------------------------------------------------------------------------------------------------- - TEST_RESULT_BOOL(cfgOptionValid(cfgOptConfig), false, "valid defaults to false"); - TEST_RESULT_BOOL(cfgOptionTest(cfgOptConfig), false, "option not valid for the command"); - TEST_RESULT_VOID(cfgOptionValidSet(cfgOptConfig, true), "set valid"); - TEST_RESULT_BOOL(cfgOptionValid(cfgOptConfig), true, "valid is set"); - TEST_RESULT_BOOL(cfgOptionTest(cfgOptConfig), false, "option valid but value is null"); - TEST_RESULT_VOID(cfgOptionSet(cfgOptConfig, cfgSourceParam, varNewStrZ("cfg")), "set option config"); - TEST_RESULT_BOOL(cfgOptionTest(cfgOptConfig), true, "option valid and value not null"); - - // ------------------------------------------------------------------------------------------------------------------------- - TEST_TITLE("option groups"); - - TEST_RESULT_BOOL(cfgOptionGroupValid(cfgOptGrpPg), false, "pg option group is not valid"); - TEST_RESULT_BOOL(cfgOptionGroupIdxTest(cfgOptGrpPg, 0), false, "pg option group index 0 is not set"); - TEST_RESULT_UINT(cfgOptionGroupIdxTotal(cfgOptGrpPg), 0, "pg option group index total is 0"); - - TEST_RESULT_VOID(cfgOptionValidSet(cfgOptPgPath + 1, true), "set pg1-path valid"); - TEST_RESULT_BOOL(cfgOptionGroupValid(cfgOptGrpPg), true, "pg option group is valid"); - TEST_RESULT_BOOL(cfgOptionGroupIdxTest(cfgOptGrpPg, 0), true, "pg option group index 0 is set"); - TEST_RESULT_BOOL(cfgOptionGroupIdxTest(cfgOptGrpPg, 1), false, "pg option group index 1 is not set"); - TEST_RESULT_UINT(cfgOptionGroupIdxTotal(cfgOptGrpPg), 1, "pg option group index total is 1"); - - TEST_RESULT_VOID(cfgOptionValidSet(cfgOptPgPath + 7, true), "set pg7-path valid"); - TEST_RESULT_VOID(cfgOptionSet(cfgOptPgPath + 7, cfgSourceParam, VARSTRDEF("/path")), "set pg7-path"); - TEST_RESULT_BOOL(cfgOptionGroupIdxTest(cfgOptGrpPg, 1), false, "pg option group index 1 is not set"); - TEST_RESULT_BOOL(cfgOptionGroupIdxTest(cfgOptGrpPg, 7), true, "pg option group index 7 is set"); - TEST_RESULT_UINT(cfgOptionGroupIdxTotal(cfgOptGrpPg), 8, "pg option group index total is 8"); - - TEST_RESULT_VOID(cfgOptionValidSet(cfgOptPgPath + 5, true), "set pg5-path valid"); - TEST_RESULT_VOID(cfgOptionSet(cfgOptPgPath + 5, cfgSourceDefault, VARSTRDEF("/path")), "set pg5-path"); - TEST_RESULT_BOOL(cfgOptionGroupIdxTest(cfgOptGrpPg, 5), false, "pg option group index 5 is not set"); - TEST_RESULT_UINT(cfgOptionGroupIdxTotal(cfgOptGrpPg), 8, "pg option group index total is 8"); - - // ------------------------------------------------------------------------------------------------------------------------- - TEST_RESULT_PTR(cfgOption(cfgOptOnline), NULL, "online is null"); - TEST_RESULT_VOID(cfgOptionSet(cfgOptOnline, cfgSourceParam, varNewBool(false)), "set online"); - TEST_RESULT_VOID(cfgOptionValidSet(cfgOptOnline, true), "set online valid"); - TEST_RESULT_BOOL(cfgOptionBool(cfgOptOnline), false, "online is set"); - TEST_RESULT_VOID(cfgOptionSet(cfgOptOnline, cfgSourceParam, varNewStrZ("1")), "set online"); - TEST_RESULT_BOOL(cfgOptionBool(cfgOptOnline), true, "online is set"); - TEST_RESULT_INT(cfgOptionSource(cfgOptOnline), cfgSourceParam, "online source is set"); - TEST_ERROR(cfgOptionDbl(cfgOptOnline), AssertError, "option 'online' is type 0 but 1 was requested"); - TEST_ERROR(cfgOptionInt64(cfgOptOnline), AssertError, "option 'online' is type 0 but 3 was requested"); - - TEST_RESULT_VOID(cfgOptionSet(cfgOptCompressLevel, cfgSourceParam, varNewInt64(1)), "set compress-level"); - TEST_RESULT_VOID(cfgOptionValidSet(cfgOptCompressLevel, true), "set compress-level valid"); - TEST_RESULT_INT(cfgOptionInt(cfgOptCompressLevel), 1, "compress-level is set"); - TEST_RESULT_VOID(cfgOptionSet(cfgOptCompressLevel, cfgSourceDefault, varNewStrZ("3")), "set compress-level"); - TEST_RESULT_INT(cfgOptionUInt(cfgOptCompressLevel), 3, "compress-level is set"); - TEST_RESULT_INT(cfgOptionSource(cfgOptCompressLevel), cfgSourceDefault, "compress source is set"); - TEST_ERROR(cfgOptionBool(cfgOptCompressLevel), AssertError, "option 'compress-level' is type 3 but 0 was requested"); - - TEST_RESULT_VOID( - cfgOptionSet(cfgOptArchivePushQueueMax, cfgSourceParam, varNewInt64(999999999999)), "set archive-push-queue-max"); - TEST_RESULT_VOID(cfgOptionValidSet(cfgOptArchivePushQueueMax, true), "set archive-push-queue-max valid"); - TEST_RESULT_INT(cfgOptionInt64(cfgOptArchivePushQueueMax), 999999999999, "archive-push-queue-max is set"); - TEST_RESULT_UINT(cfgOptionUInt64(cfgOptArchivePushQueueMax), 999999999999, "archive-push-queue-max is set"); - - TEST_RESULT_VOID(cfgOptionSet(cfgOptProtocolTimeout, cfgSourceParam, varNewDbl(1.1)), "set protocol-timeout"); - TEST_RESULT_VOID(cfgOptionValidSet(cfgOptProtocolTimeout, true), "set protocol-timeout valid"); - TEST_RESULT_DOUBLE(cfgOptionDbl(cfgOptProtocolTimeout), 1.1, "protocol-timeout is set"); - TEST_RESULT_VOID(cfgOptionSet(cfgOptProtocolTimeout, cfgSourceConfig, varNewStrZ("3.3")), "set protocol-timeout"); - TEST_RESULT_DOUBLE(cfgOptionDbl(cfgOptProtocolTimeout), 3.3, "protocol-timeout is set"); - TEST_RESULT_INT(cfgOptionSource(cfgOptProtocolTimeout), cfgSourceConfig, "protocol-timeout source is set"); - TEST_ERROR(cfgOptionKv(cfgOptProtocolTimeout), AssertError, "option 'protocol-timeout' is type 1 but 4 was requested"); - - TEST_RESULT_VOID(cfgOptionSet(cfgOptProtocolTimeout, cfgSourceConfig, NULL), "set protocol-timeout to NULL"); - TEST_RESULT_PTR(cfgOption(cfgOptProtocolTimeout), NULL, "protocol-timeout is not set"); - - TEST_ERROR( - cfgOptionSet(cfgOptRecoveryOption, cfgSourceParam, varNewDbl(1.1)), AssertError, - "option 'recovery-option' must be set with KeyValue variant"); - TEST_RESULT_VOID(cfgOptionSet(cfgOptRecoveryOption, cfgSourceConfig, varNewKv(kvNew())), "set recovery-option"); - TEST_RESULT_VOID(cfgOptionValidSet(cfgOptRecoveryOption, true), "set recovery-option valid"); - TEST_RESULT_INT(varLstSize(kvKeyList(cfgOptionKv(cfgOptRecoveryOption))), 0, "recovery-option is set"); - TEST_ERROR(cfgOptionLst(cfgOptRecoveryOption), AssertError, "option 'recovery-option' is type 4 but 8 was requested"); - - TEST_RESULT_VOID(cfgOptionValidSet(cfgOptDbInclude, true), "set db-include valid"); - TEST_RESULT_INT(varLstSize(cfgOptionLst(cfgOptDbInclude)), 0, "db-include defaults to empty"); - TEST_ERROR( - cfgOptionSet(cfgOptDbInclude, cfgSourceParam, varNewDbl(1.1)), AssertError, - "option 'db-include' must be set with VariantList variant"); - TEST_RESULT_VOID(cfgOptionSet(cfgOptDbInclude, cfgSourceConfig, varNewVarLst(varLstNew())), "set db-include"); - TEST_RESULT_INT(varLstSize(cfgOptionLst(cfgOptDbInclude)), 0, "db-include is set"); - TEST_ERROR(cfgOptionStr(cfgOptDbInclude), AssertError, "option 'db-include' is type 8 but 5 was requested"); - - TEST_ERROR(cfgOptionStr(cfgOptStanza), AssertError, "option 'stanza' is not valid for the current command"); - TEST_RESULT_VOID(cfgOptionValidSet(cfgOptStanza, true), "set stanza valid"); - TEST_ERROR(cfgOptionStr(cfgOptStanza), AssertError, "option 'stanza' is null but non-null was requested"); - TEST_RESULT_STR(cfgOptionStrNull(cfgOptStanza), NULL, "stanza defaults to null"); - TEST_ERROR( - cfgOptionSet(cfgOptStanza, cfgSourceParam, varNewDbl(1.1)), AssertError, - "option 'stanza' must be set with String variant"); - TEST_RESULT_VOID(cfgOptionSet(cfgOptStanza, cfgSourceConfig, varNewStrZ("db")), "set stanza"); - TEST_RESULT_STR_Z(cfgOptionStr(cfgOptStanza), "db", "stanza is set"); - TEST_ERROR(cfgOptionInt(cfgOptStanza), AssertError, "option 'stanza' is type 5 but 3 was requested"); - - // ------------------------------------------------------------------------------------------------------------------------- - TEST_RESULT_VOID(cfgInit(), "config init resets value"); - TEST_RESULT_INT(cfgCommand(), cfgCmdNone, "command begins as none"); - } - - // ***************************************************************************************************************************** - if (testBegin("cfgOptionHostPort()")) - { - unsigned int port = 55555; - - cfgInit(); - cfgCommandSet(cfgCmdBackup, cfgCmdRoleDefault); - - cfgOptionValidSet(cfgOptRepoS3Host, true); - cfgOptionSet(cfgOptRepoS3Host, cfgSourceConfig, varNewStrZ("host.com")) ; - TEST_RESULT_STR_Z(cfgOptionHostPort(cfgOptRepoS3Host, &port), "host.com", "check plain host"); - TEST_RESULT_UINT(port, 55555, "check that port was not updated"); - - cfgOptionSet(cfgOptRepoS3Host, cfgSourceConfig, varNewStrZ("myhost.com:777")) ; - TEST_RESULT_STR_Z(cfgOptionHostPort(cfgOptRepoS3Host, &port), "myhost.com", "check host with port"); - TEST_RESULT_UINT(port, 777, "check that port was updated"); - - TEST_RESULT_STR_Z(cfgOptionHostPort(cfgOptRepoS3Endpoint, &port), NULL, "check null host"); - TEST_RESULT_UINT(port, 777, "check that port was not updated"); - - cfgOptionSet(cfgOptRepoS3Host, cfgSourceConfig, varNewStrZ("myhost.com:777:888")) ; - TEST_ERROR( - cfgOptionHostPort(cfgOptRepoS3Host, &port), OptionInvalidError, - "'myhost.com:777:888' is not valid for option 'repo1-s3-host'" - "\nHINT: is more than one port specified?"); - TEST_RESULT_UINT(port, 777, "check that port was not updated"); - - cfgOptionValidSet(cfgOptRepoS3Endpoint, true); - cfgOptionSet(cfgOptRepoS3Endpoint, cfgSourceConfig, varNewStrZ("myendpoint.com:ZZZ")) ; - TEST_ERROR( - cfgOptionHostPort(cfgOptRepoS3Endpoint, &port), OptionInvalidError, - "'myendpoint.com:ZZZ' is not valid for option 'repo1-s3-endpoint'" - "\nHINT: port is not a positive integer."); - TEST_RESULT_UINT(port, 777, "check that port was not updated"); - } - - // ***************************************************************************************************************************** - if (testBegin("cfgOptionDefault() and cfgOptionDefaultSet()")) - { - TEST_RESULT_VOID(cfgInit(), "config init"); - TEST_RESULT_VOID(cfgCommandSet(cfgCmdBackup, cfgCmdRoleDefault), "backup command"); - - TEST_ERROR( - strZ(varStr(cfgOptionDefaultValue(cfgDefOptDbInclude))), AssertError, "default value not available for option type 4"); - TEST_RESULT_STR_Z(varStr(cfgOptionDefault(cfgOptType)), "incr", "backup type default"); - TEST_RESULT_BOOL(varBool(cfgOptionDefault(cfgOptArchiveAsync)), false, "archive async default"); - TEST_RESULT_DOUBLE(varDbl(cfgOptionDefault(cfgOptProtocolTimeout)), 1830, "backup protocol-timeout default"); - TEST_RESULT_INT(varIntForce(cfgOptionDefault(cfgOptProcessMax)), 1, "backup process-max default"); - TEST_RESULT_PTR(cfgOptionDefault(cfgOptDbInclude), NULL, "backup db-include default is null"); - - TEST_RESULT_VOID(cfgOptionSet(cfgOptPgHost, cfgSourceParam, varNewStrZ("backup")), "backup host set"); - TEST_RESULT_VOID(cfgOptionDefaultSet(cfgOptPgHost, varNewStrZ("backup-default")), "backup host default"); - TEST_RESULT_VOID(cfgOptionDefaultSet(cfgOptPgHost, varNewStrZ("backup-default2")), "reset backup host default"); - TEST_RESULT_STR_Z(varStr(cfgOption(cfgOptPgHost)), "backup", "backup host value"); - TEST_RESULT_STR_Z(varStr(cfgOptionDefault(cfgOptPgHost)), "backup-default2", "backup host default"); - - TEST_RESULT_VOID(cfgOptionSet(cfgOptPgSocketPath, cfgSourceDefault, NULL), "backup pg-socket-path set"); - TEST_RESULT_VOID(cfgOptionDefaultSet(cfgOptPgSocketPath, varNewStrZ("/to/socket")), "backup pg-socket-path default"); - TEST_RESULT_VOID(cfgOptionDefaultSet(cfgOptPgSocketPath, varNewStrZ("/to/socket2")), "reset backup pg-socket-path default"); - TEST_RESULT_STR_Z(varStr(cfgOption(cfgOptPgSocketPath)), "/to/socket2", "backup pg-socket-path value"); - TEST_RESULT_STR_Z(varStr(cfgOptionDefault(cfgOptPgSocketPath)), "/to/socket2", "backup pg-socket-path value default"); - } - - FUNCTION_HARNESS_RESULT_VOID(); -} diff --git a/test/src/module/config/defineTest.c b/test/src/module/config/defineTest.c index be5739f81..4379e0ad6 100644 --- a/test/src/module/config/defineTest.c +++ b/test/src/module/config/defineTest.c @@ -16,112 +16,112 @@ testRun(void) // ***************************************************************************************************************************** if (testBegin("check known values")) { - TEST_RESULT_Z(cfgDefOptionName(cfgDefOptConfig), "config", "option name"); + TEST_RESULT_Z(cfgDefOptionName(cfgOptConfig), "config", "option name"); - TEST_RESULT_INT(cfgDefOptionId("repo-host"), cfgDefOptRepoHost, "define id"); + TEST_RESULT_INT(cfgDefOptionId("repo-host"), cfgOptRepoHost, "define id"); TEST_RESULT_INT(cfgDefOptionId(BOGUS_STR), -1, "invalid define id"); - TEST_RESULT_BOOL(cfgDefOptionAllowList(cfgCmdBackup, cfgDefOptLogLevelConsole), true, "allow list valid"); - TEST_RESULT_BOOL(cfgDefOptionAllowList(cfgCmdBackup, cfgDefOptPgHost), false, "allow list not valid"); - TEST_RESULT_BOOL(cfgDefOptionAllowList(cfgCmdBackup, cfgDefOptType), true, "command allow list valid"); + TEST_RESULT_BOOL(cfgDefOptionAllowList(cfgCmdBackup, cfgOptLogLevelConsole), true, "allow list valid"); + TEST_RESULT_BOOL(cfgDefOptionAllowList(cfgCmdBackup, cfgOptPgHost), false, "allow list not valid"); + TEST_RESULT_BOOL(cfgDefOptionAllowList(cfgCmdBackup, cfgOptType), true, "command allow list valid"); - TEST_RESULT_INT(cfgDefOptionAllowListValueTotal(cfgCmdBackup, cfgDefOptChecksumPage), 0, "allow list total = 0"); + TEST_RESULT_INT(cfgDefOptionAllowListValueTotal(cfgCmdBackup, cfgOptChecksumPage), 0, "allow list total = 0"); - TEST_RESULT_INT(cfgDefOptionAllowListValueTotal(cfgCmdBackup, cfgDefOptType), 3, "allow list total"); + TEST_RESULT_INT(cfgDefOptionAllowListValueTotal(cfgCmdBackup, cfgOptType), 3, "allow list total"); - TEST_RESULT_Z(cfgDefOptionAllowListValue(cfgCmdBackup, cfgDefOptType, 0), "full", "allow list value 0"); - TEST_RESULT_Z(cfgDefOptionAllowListValue(cfgCmdBackup, cfgDefOptType, 1), "diff", "allow list value 1"); - TEST_RESULT_Z(cfgDefOptionAllowListValue(cfgCmdBackup, cfgDefOptType, 2), "incr", "allow list value 2"); + TEST_RESULT_Z(cfgDefOptionAllowListValue(cfgCmdBackup, cfgOptType, 0), "full", "allow list value 0"); + TEST_RESULT_Z(cfgDefOptionAllowListValue(cfgCmdBackup, cfgOptType, 1), "diff", "allow list value 1"); + TEST_RESULT_Z(cfgDefOptionAllowListValue(cfgCmdBackup, cfgOptType, 2), "incr", "allow list value 2"); TEST_ERROR( - cfgDefOptionAllowListValue(cfgCmdBackup, cfgDefOptType, 3), AssertError, - "assertion 'valueId < cfgDefOptionAllowListValueTotal(commandId, optionDefId)' failed"); + cfgDefOptionAllowListValue(cfgCmdBackup, cfgOptType, 3), AssertError, + "assertion 'valueId < cfgDefOptionAllowListValueTotal(commandId, optionId)' failed"); TEST_RESULT_BOOL( - cfgDefOptionAllowListValueValid(cfgCmdBackup, cfgDefOptType, "diff"), true, "allow list value valid"); + cfgDefOptionAllowListValueValid(cfgCmdBackup, cfgOptType, "diff"), true, "allow list value valid"); TEST_RESULT_BOOL( - cfgDefOptionAllowListValueValid(cfgCmdBackup, cfgDefOptType, BOGUS_STR), false, "allow list value not valid"); + cfgDefOptionAllowListValueValid(cfgCmdBackup, cfgOptType, BOGUS_STR), false, "allow list value not valid"); - TEST_RESULT_BOOL(cfgDefOptionAllowRange(cfgCmdBackup, cfgDefOptCompressLevel), true, "range allowed"); - TEST_RESULT_BOOL(cfgDefOptionAllowRange(cfgCmdBackup, cfgDefOptRepoHost), false, "range not allowed"); + TEST_RESULT_BOOL(cfgDefOptionAllowRange(cfgCmdBackup, cfgOptCompressLevel), true, "range allowed"); + TEST_RESULT_BOOL(cfgDefOptionAllowRange(cfgCmdBackup, cfgOptRepoHost), false, "range not allowed"); - TEST_RESULT_DOUBLE(cfgDefOptionAllowRangeMin(cfgCmdBackup, cfgDefOptDbTimeout), 0.1, "range min"); - TEST_RESULT_DOUBLE(cfgDefOptionAllowRangeMax(cfgCmdBackup, cfgDefOptCompressLevel), 9, "range max"); - TEST_RESULT_DOUBLE(cfgDefOptionAllowRangeMin(cfgCmdArchivePush, cfgDefOptArchivePushQueueMax), 0, "range min"); + TEST_RESULT_DOUBLE(cfgDefOptionAllowRangeMin(cfgCmdBackup, cfgOptDbTimeout), 0.1, "range min"); + TEST_RESULT_DOUBLE(cfgDefOptionAllowRangeMax(cfgCmdBackup, cfgOptCompressLevel), 9, "range max"); + TEST_RESULT_DOUBLE(cfgDefOptionAllowRangeMin(cfgCmdArchivePush, cfgOptArchivePushQueueMax), 0, "range min"); TEST_RESULT_DOUBLE( - cfgDefOptionAllowRangeMax(cfgCmdArchivePush, cfgDefOptArchivePushQueueMax), 4503599627370496, "range max"); + cfgDefOptionAllowRangeMax(cfgCmdArchivePush, cfgOptArchivePushQueueMax), 4503599627370496, "range max"); TEST_ERROR( - cfgDefOptionDefault(cfgDefCommandTotal(), cfgDefOptCompressLevel), AssertError, + cfgDefOptionDefault(cfgDefCommandTotal(), cfgOptCompressLevel), AssertError, "assertion 'commandId < cfgDefCommandTotal()' failed"); TEST_ERROR(cfgDefOptionDefault( cfgCmdBackup, cfgDefOptionTotal()), AssertError, - "assertion 'optionDefId < cfgDefOptionTotal()' failed"); - TEST_RESULT_Z(cfgDefOptionDefault(cfgCmdRestore, cfgDefOptType), "default", "command default exists"); - TEST_RESULT_Z(cfgDefOptionDefault(cfgCmdBackup, cfgDefOptRepoHost), NULL, "default does not exist"); + "assertion 'optionId < cfgDefOptionTotal()' failed"); + TEST_RESULT_Z(cfgDefOptionDefault(cfgCmdRestore, cfgOptType), "default", "command default exists"); + TEST_RESULT_Z(cfgDefOptionDefault(cfgCmdBackup, cfgOptRepoHost), NULL, "default does not exist"); - TEST_RESULT_BOOL(cfgDefOptionDepend(cfgCmdRestore, cfgDefOptRepoS3Key), true, "has depend option"); - TEST_RESULT_BOOL(cfgDefOptionDepend(cfgCmdRestore, cfgDefOptType), false, "does not have depend option"); + TEST_RESULT_BOOL(cfgDefOptionDepend(cfgCmdRestore, cfgOptRepoS3Key), true, "has depend option"); + TEST_RESULT_BOOL(cfgDefOptionDepend(cfgCmdRestore, cfgOptType), false, "does not have depend option"); - TEST_RESULT_INT(cfgDefOptionDependOption(cfgCmdBackup, cfgDefOptPgHostUser), cfgDefOptPgHost, "depend option id"); - TEST_RESULT_INT(cfgDefOptionDependOption(cfgCmdBackup, cfgDefOptRepoHostCmd), cfgDefOptRepoHost, "depend option id"); + TEST_RESULT_INT(cfgDefOptionDependOption(cfgCmdBackup, cfgOptPgHostUser), cfgOptPgHost, "depend option id"); + TEST_RESULT_INT(cfgDefOptionDependOption(cfgCmdBackup, cfgOptRepoHostCmd), cfgOptRepoHost, "depend option id"); - TEST_RESULT_INT(cfgDefOptionDependValueTotal(cfgCmdRestore, cfgDefOptTarget), 3, "depend option value total"); - TEST_RESULT_Z(cfgDefOptionDependValue(cfgCmdRestore, cfgDefOptTarget, 0), "name", "depend option value 0"); - TEST_RESULT_Z(cfgDefOptionDependValue(cfgCmdRestore, cfgDefOptTarget, 1), "time", "depend option value 1"); - TEST_RESULT_Z(cfgDefOptionDependValue(cfgCmdRestore, cfgDefOptTarget, 2), "xid", "depend option value 2"); + TEST_RESULT_INT(cfgDefOptionDependValueTotal(cfgCmdRestore, cfgOptTarget), 3, "depend option value total"); + TEST_RESULT_Z(cfgDefOptionDependValue(cfgCmdRestore, cfgOptTarget, 0), "name", "depend option value 0"); + TEST_RESULT_Z(cfgDefOptionDependValue(cfgCmdRestore, cfgOptTarget, 1), "time", "depend option value 1"); + TEST_RESULT_Z(cfgDefOptionDependValue(cfgCmdRestore, cfgOptTarget, 2), "xid", "depend option value 2"); TEST_ERROR( - cfgDefOptionDependValue(cfgCmdRestore, cfgDefOptTarget, 3), AssertError, - "assertion 'valueId < cfgDefOptionDependValueTotal(commandId, optionDefId)' failed"); + cfgDefOptionDependValue(cfgCmdRestore, cfgOptTarget, 3), AssertError, + "assertion 'valueId < cfgDefOptionDependValueTotal(commandId, optionId)' failed"); TEST_RESULT_BOOL( - cfgDefOptionDependValueValid(cfgCmdRestore, cfgDefOptTarget, "time"), true, "depend option value valid"); + cfgDefOptionDependValueValid(cfgCmdRestore, cfgOptTarget, "time"), true, "depend option value valid"); TEST_RESULT_BOOL( - cfgDefOptionDependValueValid(cfgCmdRestore, cfgDefOptTarget, BOGUS_STR), false, "depend option value not valid"); + cfgDefOptionDependValueValid(cfgCmdRestore, cfgOptTarget, BOGUS_STR), false, "depend option value not valid"); TEST_ERROR( cfgDefOptionIndexTotal(cfgDefOptionTotal()), AssertError, - "assertion 'optionDefId < cfgDefOptionTotal()' failed"); - TEST_RESULT_INT(cfgDefOptionIndexTotal(cfgDefOptPgPath), 8, "index total > 1"); - TEST_RESULT_INT(cfgDefOptionIndexTotal(cfgDefOptRepoPath), 1, "index total == 1"); + "assertion 'optionId < cfgDefOptionTotal()' failed"); + TEST_RESULT_INT(cfgDefOptionIndexTotal(cfgOptPgPath), 8, "index total > 1"); + TEST_RESULT_INT(cfgDefOptionIndexTotal(cfgOptRepoPath), 1, "index total == 1"); - TEST_RESULT_BOOL(cfgDefOptionInternal(cfgCmdRestore, cfgDefOptSet), false, "option set is not internal"); - TEST_RESULT_BOOL(cfgDefOptionInternal(cfgCmdRestore, cfgDefOptPgHost), true, "option pg-host is internal"); + TEST_RESULT_BOOL(cfgDefOptionInternal(cfgCmdRestore, cfgOptSet), false, "option set is not internal"); + TEST_RESULT_BOOL(cfgDefOptionInternal(cfgCmdRestore, cfgOptPgHost), true, "option pg-host is internal"); - TEST_RESULT_BOOL(cfgDefOptionMulti(cfgDefOptRecoveryOption), true, "recovery-option is multi"); - TEST_RESULT_BOOL(cfgDefOptionMulti(cfgDefOptDbInclude), true, "db-include is multi"); - TEST_RESULT_BOOL(cfgDefOptionMulti(cfgDefOptStartFast), false, "start-fast is not multi"); + TEST_RESULT_BOOL(cfgDefOptionMulti(cfgOptRecoveryOption), true, "recovery-option is multi"); + TEST_RESULT_BOOL(cfgDefOptionMulti(cfgOptDbInclude), true, "db-include is multi"); + TEST_RESULT_BOOL(cfgDefOptionMulti(cfgOptStartFast), false, "start-fast is not multi"); - TEST_RESULT_BOOL(cfgDefOptionRequired(cfgCmdBackup, cfgDefOptConfig), true, "option required"); - TEST_RESULT_BOOL(cfgDefOptionRequired(cfgCmdRestore, cfgDefOptRepoHost), false, "option not required"); - TEST_RESULT_BOOL(cfgDefOptionRequired(cfgCmdInfo, cfgDefOptStanza), false, "command option not required"); + TEST_RESULT_BOOL(cfgDefOptionRequired(cfgCmdBackup, cfgOptConfig), true, "option required"); + TEST_RESULT_BOOL(cfgDefOptionRequired(cfgCmdRestore, cfgOptRepoHost), false, "option not required"); + TEST_RESULT_BOOL(cfgDefOptionRequired(cfgCmdInfo, cfgOptStanza), false, "command option not required"); - TEST_RESULT_INT(cfgDefOptionSection(cfgDefOptRepoS3Key), cfgDefSectionGlobal, "global section"); - TEST_RESULT_INT(cfgDefOptionSection(cfgDefOptPgPath), cfgDefSectionStanza, "stanza section"); - TEST_RESULT_INT(cfgDefOptionSection(cfgDefOptType), cfgDefSectionCommandLine, "command line only"); + TEST_RESULT_INT(cfgDefOptionSection(cfgOptRepoS3Key), cfgDefSectionGlobal, "global section"); + TEST_RESULT_INT(cfgDefOptionSection(cfgOptPgPath), cfgDefSectionStanza, "stanza section"); + TEST_RESULT_INT(cfgDefOptionSection(cfgOptType), cfgDefSectionCommandLine, "command line only"); - TEST_RESULT_BOOL(cfgDefOptionSecure(cfgDefOptRepoS3Key), true, "option secure"); - TEST_RESULT_BOOL(cfgDefOptionSecure(cfgDefOptRepoHost), false, "option not secure"); + TEST_RESULT_BOOL(cfgDefOptionSecure(cfgOptRepoS3Key), true, "option secure"); + TEST_RESULT_BOOL(cfgDefOptionSecure(cfgOptRepoHost), false, "option not secure"); - TEST_RESULT_INT(cfgDefOptionType(cfgDefOptType), cfgDefOptTypeString, "string type"); - TEST_RESULT_INT(cfgDefOptionType(cfgDefOptDelta), cfgDefOptTypeBoolean, "boolean type"); + TEST_RESULT_INT(cfgDefOptionType(cfgOptType), cfgDefOptTypeString, "string type"); + TEST_RESULT_INT(cfgDefOptionType(cfgOptDelta), cfgDefOptTypeBoolean, "boolean type"); TEST_ERROR( cfgDefOptionValid(cfgCmdInfo, cfgDefOptionTotal()), AssertError, - "assertion 'optionDefId < cfgDefOptionTotal()' failed"); - TEST_RESULT_BOOL(cfgDefOptionValid(cfgCmdBackup, cfgDefOptType), true, "option valid"); - TEST_RESULT_BOOL(cfgDefOptionValid(cfgCmdInfo, cfgDefOptType), false, "option not valid"); + "assertion 'optionId < cfgDefOptionTotal()' failed"); + TEST_RESULT_BOOL(cfgDefOptionValid(cfgCmdBackup, cfgOptType), true, "option valid"); + TEST_RESULT_BOOL(cfgDefOptionValid(cfgCmdInfo, cfgOptType), false, "option not valid"); } // ***************************************************************************************************************************** if (testBegin("cfgDefCommandHelp*() and cfgDefOptionHelp*()")) { - TEST_RESULT_BOOL(cfgDefOptionHelpNameAlt(cfgDefOptRepoHost), true, "name alt exists"); - TEST_RESULT_BOOL(cfgDefOptionHelpNameAlt(cfgDefOptSet), false, "name alt not exists"); - TEST_RESULT_INT(cfgDefOptionHelpNameAltValueTotal(cfgDefOptRepoHost), 1, "name alt value total"); - TEST_RESULT_Z(cfgDefOptionHelpNameAltValue(cfgDefOptRepoHost, 0), "backup-host", "name alt value 0"); + TEST_RESULT_BOOL(cfgDefOptionHelpNameAlt(cfgOptRepoHost), true, "name alt exists"); + TEST_RESULT_BOOL(cfgDefOptionHelpNameAlt(cfgOptSet), false, "name alt not exists"); + TEST_RESULT_INT(cfgDefOptionHelpNameAltValueTotal(cfgOptRepoHost), 1, "name alt value total"); + TEST_RESULT_Z(cfgDefOptionHelpNameAltValue(cfgOptRepoHost, 0), "backup-host", "name alt value 0"); TEST_ERROR( - cfgDefOptionHelpNameAltValue(cfgDefOptRepoHost, 1), AssertError, - "assertion 'valueId < cfgDefOptionHelpNameAltValueTotal(optionDefId)' failed"); + cfgDefOptionHelpNameAltValue(cfgOptRepoHost, 1), AssertError, + "assertion 'valueId < cfgDefOptionHelpNameAltValueTotal(optionId)' failed"); TEST_RESULT_Z(cfgDefCommandHelpSummary(cfgCmdBackup), "Backup a database cluster.", "backup command help summary"); TEST_RESULT_Z( @@ -129,18 +129,18 @@ testRun(void) "pgBackRest does not have a built-in scheduler so it's best to run it from cron or some other scheduling mechanism.", "backup command help description"); - TEST_RESULT_Z(cfgDefOptionHelpSection(cfgDefOptDelta), "general", "delta option help section"); + TEST_RESULT_Z(cfgDefOptionHelpSection(cfgOptDelta), "general", "delta option help section"); TEST_RESULT_Z( - cfgDefOptionHelpSummary(cfgCmdBackup, cfgDefOptBufferSize), "Buffer size for file operations.", + cfgDefOptionHelpSummary(cfgCmdBackup, cfgOptBufferSize), "Buffer size for file operations.", "backup command, delta option help summary"); TEST_RESULT_Z( - cfgDefOptionHelpSummary(cfgCmdBackup, cfgDefOptType), "Backup type.", "backup command, type option help summary"); + cfgDefOptionHelpSummary(cfgCmdBackup, cfgOptType), "Backup type.", "backup command, type option help summary"); TEST_RESULT_Z( - cfgDefOptionHelpDescription(cfgCmdBackup, cfgDefOptLogSubprocess), + cfgDefOptionHelpDescription(cfgCmdBackup, cfgOptLogSubprocess), "Enable file logging for any subprocesses created by this process using the log level specified by log-level-file.", "backup command, log-subprocess option help description"); TEST_RESULT_Z( - cfgDefOptionHelpDescription(cfgCmdBackup, cfgDefOptType), + cfgDefOptionHelpDescription(cfgCmdBackup, cfgOptType), "The following backup types are supported:\n" "\n" "* full - all database cluster files will be copied and there will be no dependencies on previous backups.\n" diff --git a/test/src/module/config/loadTest.c b/test/src/module/config/loadTest.c index 7f3c93dac..d524377e0 100644 --- a/test/src/module/config/loadTest.c +++ b/test/src/module/config/loadTest.c @@ -61,8 +61,8 @@ testRun(void) hrnCfgArgKeyRawZ(argList, cfgOptPgHostCmd, 2, "pg2-exe"); harnessCfgLoad(cfgCmdCheck, argList); - TEST_RESULT_STR_Z(cfgOptionStr(cfgOptPgHostCmd + 0), testProjectExe(), " check pg1-host-cmd"); - TEST_RESULT_STR_Z(cfgOptionStr(cfgOptPgHostCmd + 1), "pg2-exe", " check pg2-host-cmd"); + TEST_RESULT_STR_Z(cfgOptionIdxStr(cfgOptPgHostCmd, 0), testProjectExe(), " check pg1-host-cmd"); + TEST_RESULT_STR_Z(cfgOptionIdxStr(cfgOptPgHostCmd, 1), "pg2-exe", " check pg2-host-cmd"); // ------------------------------------------------------------------------------------------------------------------------- TEST_TITLE("db-timeout set but not protocol timeout"); @@ -73,7 +73,7 @@ testRun(void) hrnCfgArgRawZ(argList, cfgOptDbTimeout, "100"); harnessCfgLoad(cfgCmdCheck, argList); - cfgOptionValidSet(cfgOptProtocolTimeout, false); + cfgOptionInvalidate(cfgOptProtocolTimeout); cfgLoadUpdateOption(); TEST_RESULT_DOUBLE(cfgOptionDbl(cfgOptDbTimeout), 100, "check db-timeout"); @@ -87,7 +87,7 @@ testRun(void) hrnCfgArgRawZ(argList, cfgOptProtocolTimeout, "100"); harnessCfgLoad(cfgCmdCheck, argList); - cfgOptionValidSet(cfgOptDbTimeout, false); + cfgOptionInvalidate(cfgOptDbTimeout); cfgLoadUpdateOption(); TEST_RESULT_DOUBLE(cfgOptionDbl(cfgOptProtocolTimeout), 100, "check protocol-timeout"); @@ -143,7 +143,7 @@ testRun(void) TEST_TITLE("only pg can be remote"); // We'll have to cheat here and invalidate the repo-host option since there are currently no pg-only commands - cfgOptionValidSet(cfgOptRepoHost, false); + cfgOptionInvalidate(cfgOptRepoHost); cfgLoadUpdateOption(); // ------------------------------------------------------------------------------------------------------------------------- @@ -519,7 +519,7 @@ testRun(void) strLstAdd(argList, strNewFmt("--log-path=%s", testPath())); hrnCfgArgRawZ(argList, cfgOptPgPath, "/path/to"); strLstAdd(argList, strNew("--process=1")); - strLstAdd(argList, strNew("--host-id=1")); + hrnCfgArgRawZ(argList, cfgOptPg, "1"); strLstAddZ(argList, "--" CFGOPT_REMOTE_TYPE "=" PROTOCOL_REMOTE_TYPE_REPO); strLstAdd(argList, strNew("--log-level-file=warn")); hrnCfgArgRawZ(argList, cfgOptExecId, "1111-fe70d611"); diff --git a/test/src/module/config/parseTest.c b/test/src/module/config/parseTest.c index 0bfc39129..8ecde2798 100644 --- a/test/src/module/config/parseTest.c +++ b/test/src/module/config/parseTest.c @@ -23,7 +23,8 @@ testOptionFind(const char *optionName, unsigned int optionId, unsigned int optio CfgParseOptionResult option = cfgParseOption(STR(optionName)); TEST_RESULT_BOOL(option.found, true, "check %s found", optionName); - TEST_RESULT_UINT(option.id, optionId + optionKeyIdx, "check %s id %u", optionName, optionId + optionKeyIdx); + TEST_RESULT_UINT(option.id, optionId, "check %s id %u", optionName, optionId); + TEST_RESULT_UINT(option.keyIdx, optionKeyIdx, "check %s key idx %u", optionName, optionKeyIdx); TEST_RESULT_BOOL(option.negate, negate, "check %s negate %d", optionName, negate); TEST_RESULT_BOOL(option.reset, reset, "check %s reset %d", optionName, reset); TEST_RESULT_BOOL(option.deprecated, deprecated, "check %s deprecated %d", optionName, deprecated); @@ -37,6 +38,15 @@ testRun(void) { FUNCTION_HARNESS_VOID(); + // Config functions that are not tested with parse + // ***************************************************************************************************************************** + if (testBegin("cfg*()")) + { + TEST_TITLE("config command defaults to none before cfgInit()"); + + TEST_RESULT_UINT(cfgCommand(), cfgCmdNone, "command is none"); + } + // config and config-include-path options // ***************************************************************************************************************************** if (testBegin("cfgFileLoad()")) @@ -136,28 +146,37 @@ testRun(void) strZ(strNewFmt("%s/global-backup.confsave", strZ(configIncludePath)))); // Set up defaults - String *backupCmdDefConfigValue = strNew(cfgDefOptionDefault( - cfgCommandId(TEST_COMMAND_BACKUP, true), cfgOptionDefIdFromId(cfgOptConfig))); - String *backupCmdDefConfigInclPathValue = strNew(cfgDefOptionDefault( - cfgCommandId(TEST_COMMAND_BACKUP, true), cfgOptionDefIdFromId(cfgOptConfigIncludePath))); + String *backupCmdDefConfigValue = strNew(cfgDefOptionDefault(cfgCommandId(TEST_COMMAND_BACKUP), cfgOptConfig)); + String *backupCmdDefConfigInclPathValue = strNew( + cfgDefOptionDefault(cfgCommandId(TEST_COMMAND_BACKUP), cfgOptConfigIncludePath)); String *oldConfigDefault = strNewFmt("%s%s", testPath(), PGBACKREST_CONFIG_ORIG_PATH_FILE); // Create the option structure and initialize with 0 - ParseOption parseOptionList[CFG_OPTION_TOTAL] = {{.found = false}}; + ParseOption parseOptionList[CFG_OPTION_TOTAL] = {{0}}; StringList *value = strLstNew(); strLstAdd(value, configFile); - parseOptionList[cfgOptConfig].found = true; - parseOptionList[cfgOptConfig].source = cfgSourceParam; - parseOptionList[cfgOptConfig].valueList = value; + parseOptionList[cfgOptConfig].indexListTotal = 1; + parseOptionList[cfgOptConfig].indexList = memNew(sizeof(ParseOptionValue)); + parseOptionList[cfgOptConfig].indexList[0] = (ParseOptionValue) + { + .found = true, + .source = cfgSourceParam, + .valueList = value, + }; value = strLstNew(); strLstAdd(value, configIncludePath); - parseOptionList[cfgOptConfigIncludePath].found = true; - parseOptionList[cfgOptConfigIncludePath].source = cfgSourceParam; - parseOptionList[cfgOptConfigIncludePath].valueList = value; + parseOptionList[cfgOptConfigIncludePath].indexListTotal = 1; + parseOptionList[cfgOptConfigIncludePath].indexList = memNew(sizeof(ParseOptionValue)); + parseOptionList[cfgOptConfigIncludePath].indexList[0] = (ParseOptionValue) + { + .found = true, + .source = cfgSourceParam, + .valueList = value, + }; TEST_RESULT_VOID(cfgFileLoadPart(NULL, NULL), "check null part"); @@ -179,7 +198,7 @@ testRun(void) value = strLstNew(); strLstAddZ(value, BOGUS_STR); - parseOptionList[cfgOptConfigIncludePath].valueList = value; + parseOptionList[cfgOptConfigIncludePath].indexList[0].valueList = value; TEST_ERROR( cfgFileLoad(parseOptionList, backupCmdDefConfigValue, backupCmdDefConfigInclPathValue, oldConfigDefault), PathMissingError, @@ -189,26 +208,26 @@ testRun(void) value = strLstNew(); strLstAdd(value, configIncludePath); - parseOptionList[cfgOptConfigIncludePath].valueList = value; + parseOptionList[cfgOptConfigIncludePath].indexList[0].valueList = value; value = strLstNew(); strLstAdd(value, strNewFmt("%s/%s", testPath(), BOGUS_STR)); - parseOptionList[cfgOptConfig].valueList = value; + parseOptionList[cfgOptConfig].indexList[0].valueList = value; TEST_ERROR_FMT( cfgFileLoad(parseOptionList, backupCmdDefConfigValue, backupCmdDefConfigInclPathValue, oldConfigDefault), FileMissingError, STORAGE_ERROR_READ_MISSING, strZ(strNewFmt("%s/BOGUS", testPath()))); - strLstFree(parseOptionList[cfgOptConfig].valueList); - strLstFree(parseOptionList[cfgOptConfigIncludePath].valueList); + strLstFree(parseOptionList[cfgOptConfig].indexList[0].valueList); + strLstFree(parseOptionList[cfgOptConfigIncludePath].indexList[0].valueList); // Neither config nor config-include-path passed as parameter (defaults but none exist) //-------------------------------------------------------------------------------------------------------------------------- - parseOptionList[cfgOptConfig].found = false; - parseOptionList[cfgOptConfig].source = cfgSourceDefault; - parseOptionList[cfgOptConfigIncludePath].found = false; - parseOptionList[cfgOptConfigIncludePath].source = cfgSourceDefault; + parseOptionList[cfgOptConfig].indexList[0].found = false; + parseOptionList[cfgOptConfig].indexList[0].source = cfgSourceDefault; + parseOptionList[cfgOptConfigIncludePath].indexList[0].found = false; + parseOptionList[cfgOptConfigIncludePath].indexList[0].source = cfgSourceDefault; TEST_RESULT_STR_Z( cfgFileLoad(parseOptionList, backupCmdDefConfigValue, backupCmdDefConfigInclPathValue, oldConfigDefault), @@ -219,11 +238,11 @@ testRun(void) value = strLstNew(); strLstAdd(value, configIncludePath); - parseOptionList[cfgOptConfig].found = false; - parseOptionList[cfgOptConfig].source = cfgSourceDefault; - parseOptionList[cfgOptConfigIncludePath].found = true; - parseOptionList[cfgOptConfigIncludePath].source = cfgSourceParam; - parseOptionList[cfgOptConfigIncludePath].valueList = value; + parseOptionList[cfgOptConfig].indexList[0].found = false; + parseOptionList[cfgOptConfig].indexList[0].source = cfgSourceDefault; + parseOptionList[cfgOptConfigIncludePath].indexList[0].found = true; + parseOptionList[cfgOptConfigIncludePath].indexList[0].source = cfgSourceParam; + parseOptionList[cfgOptConfigIncludePath].indexList[0].valueList = value; TEST_RESULT_STR_Z( cfgFileLoad(parseOptionList, backupCmdDefConfigValue, backupCmdDefConfigInclPathValue, oldConfigDefault), @@ -236,10 +255,10 @@ testRun(void) // config and config-include-path are "default" with files existing. Config file exists in both current default and old // default location - old location ignored. //-------------------------------------------------------------------------------------------------------------------------- - parseOptionList[cfgOptConfig].found = false; - parseOptionList[cfgOptConfig].source = cfgSourceDefault; - parseOptionList[cfgOptConfigIncludePath].found = false; - parseOptionList[cfgOptConfigIncludePath].source = cfgSourceDefault; + parseOptionList[cfgOptConfig].indexList[0].found = false; + parseOptionList[cfgOptConfig].indexList[0].source = cfgSourceDefault; + parseOptionList[cfgOptConfigIncludePath].indexList[0].found = false; + parseOptionList[cfgOptConfigIncludePath].indexList[0].source = cfgSourceDefault; mkdir(strZ(strPath(oldConfigDefault)), 0750); storagePut( @@ -268,11 +287,11 @@ testRun(void) value = strLstNew(); strLstAdd(value, configIncludePath); - parseOptionList[cfgOptConfig].found = false; - parseOptionList[cfgOptConfig].source = cfgSourceDefault; - parseOptionList[cfgOptConfigIncludePath].found = true; - parseOptionList[cfgOptConfigIncludePath].source = cfgSourceParam; - parseOptionList[cfgOptConfigIncludePath].valueList = value; + parseOptionList[cfgOptConfig].indexList[0].found = false; + parseOptionList[cfgOptConfig].indexList[0].source = cfgSourceDefault; + parseOptionList[cfgOptConfigIncludePath].indexList[0].found = true; + parseOptionList[cfgOptConfigIncludePath].indexList[0].source = cfgSourceParam; + parseOptionList[cfgOptConfigIncludePath].indexList[0].valueList = value; TEST_RESULT_STR_Z( cfgFileLoad(parseOptionList, backupCmdDefConfigValue, backupCmdDefConfigInclPathValue, oldConfigDefault), @@ -290,12 +309,12 @@ testRun(void) value = strLstNew(); strLstAdd(value, configIncludePath); - parseOptionList[cfgOptConfig].found = true; - parseOptionList[cfgOptConfig].source = cfgSourceParam; - parseOptionList[cfgOptConfig].negate = true; - parseOptionList[cfgOptConfigIncludePath].found = true; - parseOptionList[cfgOptConfigIncludePath].source = cfgSourceParam; - parseOptionList[cfgOptConfigIncludePath].valueList = value; + parseOptionList[cfgOptConfig].indexList[0].found = true; + parseOptionList[cfgOptConfig].indexList[0].source = cfgSourceParam; + parseOptionList[cfgOptConfig].indexList[0].negate = true; + parseOptionList[cfgOptConfigIncludePath].indexList[0].found = true; + parseOptionList[cfgOptConfigIncludePath].indexList[0].source = cfgSourceParam; + parseOptionList[cfgOptConfigIncludePath].indexList[0].valueList = value; TEST_RESULT_STR_Z( cfgFileLoad(parseOptionList, backupCmdDefConfigValue, backupCmdDefConfigInclPathValue, oldConfigDefault), @@ -307,11 +326,11 @@ testRun(void) // --no-config and config-include-path default exists with files - nothing to read //-------------------------------------------------------------------------------------------------------------------------- - parseOptionList[cfgOptConfig].found = true; - parseOptionList[cfgOptConfig].source = cfgSourceParam; - parseOptionList[cfgOptConfig].negate = true; - parseOptionList[cfgOptConfigIncludePath].found = false; - parseOptionList[cfgOptConfigIncludePath].source = cfgSourceDefault; + parseOptionList[cfgOptConfig].indexList[0].found = true; + parseOptionList[cfgOptConfig].indexList[0].source = cfgSourceParam; + parseOptionList[cfgOptConfig].indexList[0].negate = true; + parseOptionList[cfgOptConfigIncludePath].indexList[0].found = false; + parseOptionList[cfgOptConfigIncludePath].indexList[0].source = cfgSourceDefault; TEST_RESULT_STR_Z( cfgFileLoad(parseOptionList, backupCmdDefConfigValue, configIncludePath, oldConfigDefault), @@ -322,12 +341,12 @@ testRun(void) value = strLstNew(); strLstAdd(value, configFile); - parseOptionList[cfgOptConfig].found = true; - parseOptionList[cfgOptConfig].source = cfgSourceParam; - parseOptionList[cfgOptConfig].negate = false; - parseOptionList[cfgOptConfig].valueList = value; - parseOptionList[cfgOptConfigIncludePath].found = false; - parseOptionList[cfgOptConfigIncludePath].source = cfgSourceDefault; + parseOptionList[cfgOptConfig].indexList[0].found = true; + parseOptionList[cfgOptConfig].indexList[0].source = cfgSourceParam; + parseOptionList[cfgOptConfig].indexList[0].negate = false; + parseOptionList[cfgOptConfig].indexList[0].valueList = value; + parseOptionList[cfgOptConfigIncludePath].indexList[0].found = false; + parseOptionList[cfgOptConfigIncludePath].indexList[0].source = cfgSourceDefault; TEST_RESULT_STR_Z( cfgFileLoad(parseOptionList, backupCmdDefConfigValue, configIncludePath, oldConfigDefault), @@ -341,11 +360,11 @@ testRun(void) value = strLstNew(); strLstAdd(value, configIncludePath); - parseOptionList[cfgOptConfig].found = false; - parseOptionList[cfgOptConfig].source = cfgSourceDefault; - parseOptionList[cfgOptConfigIncludePath].found = true; - parseOptionList[cfgOptConfigIncludePath].source = cfgSourceParam; - parseOptionList[cfgOptConfigIncludePath].valueList = value; + parseOptionList[cfgOptConfig].indexList[0].found = false; + parseOptionList[cfgOptConfig].indexList[0].source = cfgSourceDefault; + parseOptionList[cfgOptConfigIncludePath].indexList[0].found = true; + parseOptionList[cfgOptConfigIncludePath].indexList[0].source = cfgSourceParam; + parseOptionList[cfgOptConfigIncludePath].indexList[0].valueList = value; TEST_RESULT_STR_Z( cfgFileLoad(parseOptionList, configFile, backupCmdDefConfigInclPathValue, oldConfigDefault), @@ -361,10 +380,10 @@ testRun(void) // config and config-include-path are "default". //-------------------------------------------------------------------------------------------------------------------------- - parseOptionList[cfgOptConfig].found = false; - parseOptionList[cfgOptConfig].source = cfgSourceDefault; - parseOptionList[cfgOptConfigIncludePath].found = false; - parseOptionList[cfgOptConfigIncludePath].source = cfgSourceDefault; + parseOptionList[cfgOptConfig].indexList[0].found = false; + parseOptionList[cfgOptConfig].indexList[0].source = cfgSourceDefault; + parseOptionList[cfgOptConfigIncludePath].indexList[0].found = false; + parseOptionList[cfgOptConfigIncludePath].indexList[0].source = cfgSourceDefault; // File exists in old default config location but not in current default. TEST_RESULT_STR_Z( @@ -382,9 +401,14 @@ testRun(void) value = strLstNew(); strLstAddZ(value, testPath()); - parseOptionList[cfgOptConfigPath].found = true; - parseOptionList[cfgOptConfigPath].source = cfgSourceParam; - parseOptionList[cfgOptConfigPath].valueList = value; + parseOptionList[cfgOptConfigPath].indexListTotal = 1; + parseOptionList[cfgOptConfigPath].indexList = memNew(sizeof(ParseOptionValue)); + parseOptionList[cfgOptConfigPath].indexList[0] = (ParseOptionValue) + { + .found = true, + .source = cfgSourceParam, + .valueList = value, + }; // Override default paths for config and config-include-path - but no pgbackrest.conf file in override path only in old // default so ignored @@ -400,10 +424,10 @@ testRun(void) value = strLstNew(); strLstAdd(value, configFile); - parseOptionList[cfgOptConfig].found = true; - parseOptionList[cfgOptConfig].source = cfgSourceParam; - parseOptionList[cfgOptConfig].negate = false; - parseOptionList[cfgOptConfig].valueList = value; + parseOptionList[cfgOptConfig].indexList[0].found = true; + parseOptionList[cfgOptConfig].indexList[0].source = cfgSourceParam; + parseOptionList[cfgOptConfig].indexList[0].negate = false; + parseOptionList[cfgOptConfig].indexList[0].valueList = value; // Passing --config and --config-path - default config-include-path overwritten and config is required and is loaded and // config-include-path files will attempt to be loaded but not required @@ -422,7 +446,7 @@ testRun(void) value = strLstNew(); strLstAddZ(value, BOGUS_STR); - parseOptionList[cfgOptConfigPath].valueList = value; + parseOptionList[cfgOptConfigPath].indexList[0].valueList = value; // Passing --config and bogus --config-path - default config-include-path overwritten, config is required and is loaded and // config-include-path files will attempt to be loaded but doesn't exist - no error since not required @@ -440,16 +464,16 @@ testRun(void) strZ(strNewFmt("cp %s %s", strZ(configFile), strZ(strNewFmt("%s/pgbackrest.conf", testPath()))))), 0, "copy configFile to pgbackrest.conf"); - parseOptionList[cfgOptConfig].found = false; - parseOptionList[cfgOptConfig].source = cfgSourceDefault; - parseOptionList[cfgOptConfig].negate = false; - parseOptionList[cfgOptConfigIncludePath].found = false; - parseOptionList[cfgOptConfigIncludePath].source = cfgSourceDefault; + parseOptionList[cfgOptConfig].indexList[0].found = false; + parseOptionList[cfgOptConfig].indexList[0].source = cfgSourceDefault; + parseOptionList[cfgOptConfig].indexList[0].negate = false; + parseOptionList[cfgOptConfigIncludePath].indexList[0].found = false; + parseOptionList[cfgOptConfigIncludePath].indexList[0].source = cfgSourceDefault; value = strLstNew(); strLstAddZ(value, testPath()); - parseOptionList[cfgOptConfigPath].valueList = value; + parseOptionList[cfgOptConfigPath].indexList[0].valueList = value; // Override default paths for config and config-include-path with --config-path TEST_RESULT_STR_Z( @@ -465,8 +489,8 @@ testRun(void) "config-path override: config-include-path and config file read"); // Clear config-path - parseOptionList[cfgOptConfigPath].found = false; - parseOptionList[cfgOptConfigPath].source = cfgSourceDefault; + parseOptionList[cfgOptConfigPath].indexList[0].found = false; + parseOptionList[cfgOptConfigPath].indexList[0].source = cfgSourceDefault; // config default and config-include-path passed - but no config files in the include path - only in the default path // rm command is split below because code counter is confused by what looks like a comment. @@ -476,11 +500,11 @@ testRun(void) value = strLstNew(); strLstAdd(value, configIncludePath); - parseOptionList[cfgOptConfig].found = false; - parseOptionList[cfgOptConfig].source = cfgSourceDefault; - parseOptionList[cfgOptConfigIncludePath].found = true; - parseOptionList[cfgOptConfigIncludePath].source = cfgSourceParam; - parseOptionList[cfgOptConfigIncludePath].valueList = value; + parseOptionList[cfgOptConfig].indexList[0].found = false; + parseOptionList[cfgOptConfig].indexList[0].source = cfgSourceDefault; + parseOptionList[cfgOptConfigIncludePath].indexList[0].found = true; + parseOptionList[cfgOptConfigIncludePath].indexList[0].source = cfgSourceParam; + parseOptionList[cfgOptConfigIncludePath].indexList[0].valueList = value; TEST_RESULT_STR_Z( cfgFileLoad(parseOptionList, configFile, backupCmdDefConfigInclPathValue, oldConfigDefault), @@ -498,11 +522,11 @@ testRun(void) value = strLstNew(); strLstAdd(value, configIncludePath); - parseOptionList[cfgOptConfig].found = false; - parseOptionList[cfgOptConfig].source = cfgSourceDefault; - parseOptionList[cfgOptConfigIncludePath].found = true; - parseOptionList[cfgOptConfigIncludePath].source = cfgSourceParam; - parseOptionList[cfgOptConfigIncludePath].valueList = value; + parseOptionList[cfgOptConfig].indexList[0].found = false; + parseOptionList[cfgOptConfig].indexList[0].source = cfgSourceDefault; + parseOptionList[cfgOptConfigIncludePath].indexList[0].found = true; + parseOptionList[cfgOptConfigIncludePath].indexList[0].source = cfgSourceParam; + parseOptionList[cfgOptConfigIncludePath].indexList[0].valueList = value; TEST_RESULT_STR_Z( cfgFileLoad(parseOptionList, backupCmdDefConfigValue, backupCmdDefConfigInclPathValue, backupCmdDefConfigValue), @@ -783,7 +807,7 @@ testRun(void) // ------------------------------------------------------------------------------------------------------------------------- argList = strLstNew(); strLstAdd(argList, strNew("pgbackrest")); - strLstAdd(argList, strNew("--host-id=1")); + hrnCfgArgRawZ(argList, cfgOptPg, "1"); hrnCfgArgRawZ(argList, cfgOptPgPath, "/path/to"); strLstAdd(argList, strNew("--process=1")); strLstAdd(argList, strNew("--stanza=db")); @@ -794,6 +818,9 @@ testRun(void) logLevelStdOut = logLevelError; logLevelStdErr = logLevelError; TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), "load local config"); + TEST_RESULT_INT(cfgCommandRole(), cfgCmdRoleLocal, " command role is local"); + TEST_RESULT_BOOL(cfgLockRequired(), false, " backup:local command does not require lock"); + TEST_RESULT_STR_Z(cfgCommandRoleName(), "backup:local", " command/role name is backup:local"); TEST_RESULT_INT(logLevelStdOut, logLevelError, "console logging is error"); TEST_RESULT_INT(logLevelStdErr, logLevelError, "stderr logging is error"); @@ -809,6 +836,8 @@ testRun(void) logLevelStdOut = logLevelError; logLevelStdErr = logLevelError; TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), "load remote config"); + TEST_RESULT_INT(cfgCommandRole(), cfgCmdRoleRemote, " command role is remote"); + TEST_RESULT_STR_Z(cfgCommandRoleStr(cfgCmdRoleRemote), "remote", " remote role name"); TEST_RESULT_INT(logLevelStdOut, logLevelError, "console logging is error"); TEST_RESULT_INT(logLevelStdErr, logLevelError, "stderr logging is error"); harnessLogLevelReset(); @@ -1162,6 +1191,18 @@ testRun(void) setenv("PGBACKREST_REPO1_S3_KEY_SECRET", "xxx", true); TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), TEST_COMMAND_BACKUP " command"); TEST_RESULT_INT(cfgCommand(), cfgCmdBackup, " command is " TEST_COMMAND_BACKUP); + TEST_RESULT_BOOL(cfgCommandInternal(cfgCmdBackup), false, " backup command is not internal"); + TEST_RESULT_BOOL(cfgLockRequired(), true, " backup command requires lock"); + TEST_RESULT_UINT(cfgLockType(), lockTypeBackup, " backup command requires backup lock type"); + TEST_RESULT_UINT(cfgLogLevelDefault(), logLevelInfo, " backup defaults to log level warn"); + TEST_RESULT_BOOL(cfgLogFile(), true, " backup command does file logging"); + TEST_RESULT_BOOL(cfgLockRemoteRequired(), true, " backup command requires remote lock"); + TEST_RESULT_STR_Z(strLstJoin(cfgCommandParam(), "|"), "", " check command arguments"); + TEST_RESULT_UINT(cfgCommandRoleEnum(NULL), cfgCmdRoleDefault, "command role default enum"); + TEST_ERROR(cfgCommandRoleEnum(STRDEF("bogus")), CommandInvalidError, "invalid command role 'bogus'"); + TEST_RESULT_INT(cfgCommandRole(), cfgCmdRoleDefault, " command role is default"); + TEST_RESULT_STR_Z(cfgCommandRoleName(), "backup", " command/role name is backup"); + TEST_RESULT_STR_Z(cfgCommandRoleStr(cfgCmdRoleDefault), NULL, " default role name is NULL"); TEST_RESULT_STR_Z(cfgExe(), TEST_BACKREST_EXE, " exe is set"); @@ -1171,18 +1212,50 @@ testRun(void) TEST_RESULT_INT(cfgOptionSource(cfgOptStanza), cfgSourceParam, " stanza is source param"); TEST_RESULT_STR_Z(cfgOptionStr(cfgOptStanza), "db", " stanza is set"); TEST_RESULT_INT(cfgOptionSource(cfgOptStanza), cfgSourceParam, " stanza is source param"); - TEST_RESULT_STR_Z(cfgOptionStr(cfgOptPgPath), "/path/to/db", " pg1-path is set"); + TEST_RESULT_STR_Z(cfgOptionIdxStr(cfgOptPgPath, 0), "/path/to/db", " pg1-path is set"); TEST_RESULT_INT(cfgOptionSource(cfgOptPgPath), cfgSourceParam, " pg1-path is source param"); TEST_RESULT_STR_Z(cfgOptionStr(cfgOptRepoS3KeySecret), "xxx", " repo1-s3-secret is set"); TEST_RESULT_INT(cfgOptionSource(cfgOptRepoS3KeySecret), cfgSourceConfig, " repo1-s3-secret is source env"); TEST_RESULT_BOOL(cfgOptionBool(cfgOptOnline), false, " online is not set"); TEST_RESULT_INT(cfgOptionSource(cfgOptOnline), cfgSourceParam, " online is source default"); - TEST_RESULT_INT(cfgOptionInt(cfgOptBufferSize), 1048576, " buffer-size is set"); + TEST_RESULT_INT(cfgOptionIdxInt(cfgOptBufferSize, 0), 1048576, " buffer-size is set"); TEST_RESULT_INT(cfgOptionSource(cfgOptBufferSize), cfgSourceDefault, " buffer-size is source default"); + TEST_RESULT_Z(cfgOptionName(cfgOptBufferSize), "buffer-size", " buffer-size name"); unsetenv("PGBACKREST_REPO1_S3_KEY"); unsetenv("PGBACKREST_REPO1_S3_KEY_SECRET"); + // ------------------------------------------------------------------------------------------------------------------------- + TEST_TITLE("port can be parsed from hostname"); + + unsigned int port = 55555; + + cfgOptionSet(cfgOptRepoS3Host, cfgSourceConfig, varNewStrZ("host.com")) ; + TEST_RESULT_STR_Z(cfgOptionHostPort(cfgOptRepoS3Host, &port), "host.com", "check plain host"); + TEST_RESULT_UINT(port, 55555, "check that port was not updated"); + + cfgOptionSet(cfgOptRepoS3Host, cfgSourceConfig, varNewStrZ("myhost.com:777")) ; + TEST_RESULT_STR_Z(cfgOptionHostPort(cfgOptRepoS3Host, &port), "myhost.com", "check host with port"); + TEST_RESULT_UINT(port, 777, "check that port was updated"); + + cfgOptionSet(cfgOptRepoS3Endpoint, cfgSourceConfig, NULL); + TEST_RESULT_STR_Z(cfgOptionHostPort(cfgOptRepoS3Endpoint, &port), NULL, "check null host"); + TEST_RESULT_UINT(port, 777, "check that port was not updated"); + + cfgOptionSet(cfgOptRepoS3Host, cfgSourceConfig, varNewStrZ("myhost.com:777:888")) ; + TEST_ERROR( + cfgOptionHostPort(cfgOptRepoS3Host, &port), OptionInvalidError, + "'myhost.com:777:888' is not valid for option 'repo1-s3-host'" + "\nHINT: is more than one port specified?"); + TEST_RESULT_UINT(port, 777, "check that port was not updated"); + + cfgOptionSet(cfgOptRepoS3Endpoint, cfgSourceConfig, varNewStrZ("myendpoint.com:ZZZ")); + TEST_ERROR( + cfgOptionHostPort(cfgOptRepoS3Endpoint, &port), OptionInvalidError, + "'myendpoint.com:ZZZ' is not valid for option 'repo1-s3-endpoint'" + "\nHINT: port is not a positive integer."); + TEST_RESULT_UINT(port, 777, "check that port was not updated"); + // ------------------------------------------------------------------------------------------------------------------------- argList = strLstNew(); strLstAdd(argList, strNew(TEST_BACKREST_EXE)); @@ -1190,7 +1263,9 @@ testRun(void) strLstAdd(argList, strNewFmt("--config=%s", strZ(configFile))); strLstAdd(argList, strNew("--no-online")); hrnCfgArgKeyRawBool(argList, cfgOptPgLocal, 2, true); + hrnCfgArgRawZ(argList, cfgOptPg, "2"); strLstAdd(argList, strNew("--reset-pg1-host")); + strLstAdd(argList, strNew("--reset-pg3-host")); strLstAdd(argList, strNew("--reset-backup-standby")); strLstAdd(argList, strNew(TEST_COMMAND_BACKUP)); @@ -1234,8 +1309,9 @@ testRun(void) "pg1-path=/path/to/db\n" "%s=ignore\n" "%s=/path/to/db2\n" + "pg3-host=ignore\n" "recovery-option=c=d\n", - cfgOptionName(cfgOptPgHost + 1), cfgOptionName(cfgOptPgPath + 1)))); + cfgOptionKeyIdxName(cfgOptPgHost, 1), cfgOptionKeyIdxName(cfgOptPgPath, 1)))); TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), TEST_COMMAND_BACKUP " command"); harnessLogResult( @@ -1251,20 +1327,25 @@ testRun(void) "P00 WARN: configuration file contains command-line only option 'online'\n" "P00 WARN: configuration file contains stanza-only option 'pg1-path' in global section 'global:backup'"))); - TEST_RESULT_BOOL(cfgOptionTest(cfgOptPgHost), false, " pg1-host is not set (command line reset override)"); - TEST_RESULT_STR_Z(cfgOptionStr(cfgOptPgPath), "/path/to/db", " pg1-path is set"); - TEST_RESULT_BOOL(cfgOptionBool(cfgOptPgLocal + 1), true, " pg2-local is set"); - TEST_RESULT_BOOL(cfgOptionTest(cfgOptPgHost + 1), false, " pg2-host is not set (pg2-local override)"); - TEST_RESULT_STR_Z(cfgOptionStr(cfgOptPgPath + 1), "/path/to/db2", " pg2-path is set"); + TEST_RESULT_BOOL(cfgOptionIdxTest(cfgOptPgHost, 0), false, " pg1-host is not set (command line reset override)"); + TEST_RESULT_BOOL(cfgOptionIdxReset(cfgOptPgHost, 0), true, " pg1-host was reset"); + TEST_RESULT_UINT(cfgOptionGroupIdxDefault(cfgOptGrpPg), 1, " pg2 is default"); + TEST_RESULT_UINT(cfgOptionGroupIdxToKey(cfgOptGrpPg, 1), 2, " pg2 is index 1"); + TEST_RESULT_STR_Z(cfgOptionStr(cfgOptPgPath), "/path/to/db2", " default pg-path"); + TEST_RESULT_UINT(cfgOptionGroupIdxTotal(cfgOptGrpPg), 2, " pg1 and pg2 are set"); + TEST_RESULT_BOOL(cfgOptionIdxBool(cfgOptPgLocal, 1), true, " pg2-local is set"); + TEST_RESULT_BOOL(cfgOptionIdxTest(cfgOptPgHost, 1), false, " pg2-host is not set (pg2-local override)"); + TEST_RESULT_STR_Z(cfgOptionIdxStr(cfgOptPgPath, cfgOptionKeyToIdx(cfgOptPgPath, 2)), "/path/to/db2", " pg2-path is set"); TEST_RESULT_INT(cfgOptionSource(cfgOptPgPath), cfgSourceConfig, " pg1-path is source config"); TEST_RESULT_STR_Z(cfgOptionStr(cfgOptLockPath), "/", " lock-path is set"); TEST_RESULT_INT(cfgOptionSource(cfgOptLockPath), cfgSourceConfig, " lock-path is source config"); - TEST_RESULT_STR_Z(cfgOptionStr(cfgOptPgSocketPath), "/path/to/socket", " pg1-socket-path is set"); - TEST_RESULT_INT(cfgOptionSource(cfgOptPgSocketPath), cfgSourceConfig, " pg1-socket-path is config param"); + TEST_RESULT_STR_Z(cfgOptionIdxStr(cfgOptPgSocketPath, 0), "/path/to/socket", " pg1-socket-path is set"); + TEST_RESULT_INT(cfgOptionIdxSource(cfgOptPgSocketPath, 0), cfgSourceConfig, " pg1-socket-path is config param"); TEST_RESULT_BOOL(cfgOptionBool(cfgOptOnline), false, " online not is set"); TEST_RESULT_INT(cfgOptionSource(cfgOptOnline), cfgSourceParam, " online is source param"); TEST_RESULT_BOOL(cfgOptionBool(cfgOptStartFast), false, " start-fast not is set"); TEST_RESULT_INT(cfgOptionSource(cfgOptStartFast), cfgSourceConfig, " start-fast is config param"); + TEST_RESULT_UINT(cfgOptionIdxTotal(cfgOptDelta), 1, " delta not indexed"); TEST_RESULT_BOOL(cfgOptionBool(cfgOptDelta), true, " delta not set"); TEST_RESULT_INT(cfgOptionSource(cfgOptDelta), cfgSourceConfig, " delta is source config"); TEST_RESULT_BOOL(cfgOptionTest(cfgOptArchiveCheck), false, " archive-check is not set"); @@ -1275,10 +1356,38 @@ testRun(void) TEST_RESULT_INT(cfgOptionSource(cfgOptCompressLevel), cfgSourceConfig, " compress-level is source config"); TEST_RESULT_BOOL(cfgOptionBool(cfgOptBackupStandby), false, " backup-standby not is set"); TEST_RESULT_INT(cfgOptionSource(cfgOptBackupStandby), cfgSourceDefault, " backup-standby is source default"); + TEST_RESULT_BOOL(cfgOptionReset(cfgOptBackupStandby), true, " backup-standby was reset"); TEST_RESULT_BOOL(cfgOptionBool(cfgOptDelta), true, " delta is set"); TEST_RESULT_INT(cfgOptionSource(cfgOptDelta), cfgSourceConfig, " delta is source config"); TEST_RESULT_INT(cfgOptionInt64(cfgOptBufferSize), 65536, " buffer-size is set"); TEST_RESULT_INT(cfgOptionSource(cfgOptBufferSize), cfgSourceConfig, " backup-standby is source config"); + TEST_RESULT_DOUBLE(cfgOptionDbl(cfgOptDbTimeout), 1800, " db-timeout is set"); + TEST_RESULT_UINT(cfgOptionIdxUInt(cfgOptPgPort, 1), 5432, " pg2-port is set"); + TEST_RESULT_UINT(cfgOptionIdxUInt64(cfgOptPgPort, 1), 5432, " pg2-port is set"); + TEST_RESULT_STR(cfgOptionIdxStrNull(cfgOptPgHost, 1), NULL, " pg2-host is NULL"); + TEST_RESULT_STR(cfgOptionStrNull(cfgOptPgHost), NULL, " pg2-host is NULL"); + TEST_ERROR(cfgOptionStr(cfgOptPgHost), AssertError, "option 'pg2-host' is null but non-null was requested"); + + TEST_RESULT_BOOL(varBool(cfgOptionDefault(cfgOptBackupStandby)), false, " backup-standby default is false"); + TEST_RESULT_BOOL(varBool(cfgOptionDefault(cfgOptBackupStandby)), false, " backup-standby default is false (again)"); + TEST_RESULT_PTR(cfgOptionDefault(cfgOptPgHost), NULL, " pg-host default is NULL"); + TEST_RESULT_STR_Z(varStr(cfgOptionDefault(cfgOptLogLevelConsole)), "warn", " log-level-console default is warn"); + TEST_RESULT_INT(varInt64(cfgOptionDefault(cfgOptPgPort)), 5432, " pg-port default is 5432"); + TEST_RESULT_DOUBLE(varDbl(cfgOptionDefault(cfgOptDbTimeout)), 1800, " db-timeout default is 1800"); + + TEST_RESULT_VOID(cfgOptionDefaultSet(cfgOptPgSocketPath, VARSTRDEF("/default")), " set pg-socket-path default"); + TEST_RESULT_STR_Z(cfgOptionIdxStr(cfgOptPgSocketPath, 0), "/path/to/socket", " pg1-socket-path unchanged"); + TEST_RESULT_STR_Z(cfgOptionIdxStr(cfgOptPgSocketPath, 1), "/default", " pg2-socket-path is new default"); + + TEST_ERROR(cfgOptionDefaultValue(cfgOptDbInclude), AssertError, "default value not available for option type 4"); + TEST_ERROR(cfgOptionLst(cfgOptDbInclude), AssertError, "option 'db-include' is not valid for the current command"); + TEST_ERROR(cfgOptionKv(cfgOptPgPath), AssertError, "option 'pg2-path' is type 5 but 4 was requested"); + + TEST_RESULT_VOID(cfgOptionInvalidate(cfgOptPgPath), " invalidate pg-path"); + TEST_RESULT_BOOL(cfgOptionValid(cfgOptPgPath), false, " pg-path no longer valid"); + + TEST_RESULT_UINT(cfgOptionKeyToIdx(cfgOptArchiveTimeout, 1), 0, "check archive-timeout"); + TEST_ERROR(cfgOptionKeyToIdx(cfgOptPgPath, 4), AssertError, "key '4' is not valid for 'pg-path' option"); unsetenv("PGBACKREST_BOGUS"); unsetenv("PGBACKREST_NO_DELTA"); @@ -1288,6 +1397,12 @@ testRun(void) unsetenv("PGBACKREST_START_FAST"); unsetenv("PGBACKREST_PG1_SOCKET_PATH"); + // ------------------------------------------------------------------------------------------------------------------------- + TEST_TITLE("set command to expire"); + + TEST_RESULT_VOID(cfgCommandSet(cfgCmdExpire, cfgCommandRoleEnum(STRDEF("async"))), "set command"); + TEST_RESULT_STR_Z(cfgCommandRoleName(), "expire:async", "command/role name is expire:async"); + // ------------------------------------------------------------------------------------------------------------------------- argList = strLstNew(); strLstAdd(argList, strNew(TEST_BACKREST_EXE)); @@ -1295,7 +1410,7 @@ testRun(void) strLstAdd(argList, strNew("--stanza=db")); strLstAdd(argList, strNew("--archive-push-queue-max=4503599627370496")); strLstAdd(argList, strNew("--buffer-size=2MB")); - strLstAdd(argList, strNew("archive-push")); + strLstAdd(argList, strNew("archive-push:async")); storagePutP( storageNewWriteP(storageLocalWrite(), configFile), @@ -1305,9 +1420,12 @@ testRun(void) TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), "archive-push command"); + TEST_RESULT_BOOL(cfgLockRequired(), true, " archive-push:async command requires lock"); + TEST_RESULT_BOOL(cfgLogFile(), true, " archive-push:async command does file logging"); TEST_RESULT_INT(cfgOptionInt64(cfgOptArchivePushQueueMax), 4503599627370496, "archive-push-queue-max is set"); + TEST_RESULT_UINT(cfgOptionUInt64(cfgOptArchivePushQueueMax), 4503599627370496, "archive-push-queue-max is set"); TEST_RESULT_INT(cfgOptionSource(cfgOptArchivePushQueueMax), cfgSourceParam, " archive-push-queue-max is source config"); - TEST_RESULT_INT(cfgOptionInt64(cfgOptBufferSize), 2097152, "buffer-size is set to bytes from MB"); + TEST_RESULT_INT(cfgOptionIdxInt64(cfgOptBufferSize, 0), 2097152, "buffer-size is set to bytes from MB"); TEST_RESULT_INT(cfgOptionSource(cfgOptBufferSize), cfgSourceParam, " buffer-size is source config"); TEST_RESULT_PTR(cfgOption(cfgOptSpoolPath), NULL, " spool-path is not set"); TEST_RESULT_INT(cfgOptionSource(cfgOptSpoolPath), cfgSourceDefault, " spool-path is source default"); @@ -1362,7 +1480,9 @@ testRun(void) const KeyValue *recoveryKv = NULL; TEST_ASSIGN(recoveryKv, cfgOptionKv(cfgOptRecoveryOption), "get recovery options"); TEST_RESULT_STR_Z(varStr(kvGet(recoveryKv, varNewStr(strNew("a")))), "b", "check recovery option"); + TEST_ASSIGN(recoveryKv, cfgOptionIdxKv(cfgOptRecoveryOption, 0), "get recovery options"); TEST_RESULT_STR_Z(varStr(kvGet(recoveryKv, varNewStr(strNew("c")))), "de=fg hi", "check recovery option"); + TEST_RESULT_BOOL(cfgLockRequired(), false, " restore command does not require lock"); // ------------------------------------------------------------------------------------------------------------------------- argList = strLstNew(); @@ -1386,6 +1506,7 @@ testRun(void) TEST_ASSIGN(recoveryKv, cfgOptionKv(cfgOptRecoveryOption), "get recovery options"); TEST_RESULT_STR_Z(varStr(kvGet(recoveryKv, varNewStr(strNew("f")))), "g", "check recovery option"); TEST_RESULT_STR_Z(varStr(kvGet(recoveryKv, varNewStr(strNew("hijk")))), "l", "check recovery option"); + TEST_RESULT_UINT(varLstSize(cfgOptionLst(cfgOptDbInclude)), 0, "check db include option size"); // ------------------------------------------------------------------------------------------------------------------------- argList = strLstNew(); @@ -1410,6 +1531,32 @@ testRun(void) unsetenv("PGBACKREST_RECOVERY_OPTION"); unsetenv("PGBACKREST_DB_INCLUDE"); + // ------------------------------------------------------------------------------------------------------------------------- + TEST_TITLE("cfgOptionSet() and cfgOptionIdxSet()"); + + TEST_RESULT_VOID(cfgOptionSet(cfgOptForce, cfgSourceParam, VARINT(1)), "set force true"); + TEST_RESULT_BOOL(cfgOptionBool(cfgOptForce), true, "check force"); + TEST_RESULT_VOID(cfgOptionSet(cfgOptForce, cfgSourceParam, VARBOOL(false)), "set force false"); + TEST_RESULT_BOOL(cfgOptionBool(cfgOptForce), false, "check force"); + + TEST_RESULT_VOID(cfgOptionSet(cfgOptProtocolTimeout, cfgSourceParam, VARINT(1)), "set protocol-timeout to 1"); + TEST_RESULT_DOUBLE(cfgOptionDbl(cfgOptProtocolTimeout), 1, "check protocol-timeout"); + TEST_RESULT_VOID(cfgOptionSet(cfgOptProtocolTimeout, cfgSourceParam, VARDBL(2.2)), "set protocol-timeout to 2.2"); + TEST_RESULT_DOUBLE(cfgOptionDbl(cfgOptProtocolTimeout), 2.2, "check protocol-timeout"); + + TEST_RESULT_VOID(cfgOptionSet(cfgOptProcessMax, cfgSourceParam, VARINT(50)), "set process-max to 50"); + TEST_RESULT_INT(cfgOptionInt(cfgOptProcessMax), 50, "check process-max"); + TEST_RESULT_VOID(cfgOptionSet(cfgOptProcessMax, cfgSourceParam, VARINT64(51)), "set process-max to 51"); + TEST_RESULT_INT(cfgOptionInt(cfgOptProcessMax), 51, "check process-max"); + + TEST_ERROR(cfgOptionSet(cfgOptDbInclude, cfgSourceParam, VARINT(1)), AssertError, "set not available for option type 4"); + + TEST_ERROR( + cfgOptionIdxSet(cfgOptPgPath, 0, cfgSourceParam, VARINT(1)), AssertError, + "option 'pg1-path' must be set with String variant"); + TEST_RESULT_VOID(cfgOptionIdxSet(cfgOptPgPath, 0, cfgSourceParam, VARSTRDEF("/new")), "set pg1-path"); + TEST_RESULT_STR_Z(cfgOptionIdxStr(cfgOptPgPath, 0), "/new", "check pg1-path"); + // Stanza options should not be loaded for commands that don't take a stanza // ------------------------------------------------------------------------------------------------------------------------- argList = strLstNew(); @@ -1427,7 +1574,45 @@ testRun(void) "repo1-path=/not/the/path\n")); TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), "info command"); + TEST_RESULT_BOOL(cfgLogFile(), false, " info command does not do file logging"); TEST_RESULT_STR_Z(cfgOptionStr(cfgOptRepoPath), "/path/to/repo", "check repo1-path option"); + + // ------------------------------------------------------------------------------------------------------------------------- + TEST_TITLE("info command can be forced to do file logging"); + + argList = strLstNew(); + hrnCfgArgRawZ(argList, cfgOptLogLevelFile, "detail"); + TEST_RESULT_VOID(harnessCfgLoad(cfgCmdInfo, argList), "info command"); + + TEST_RESULT_BOOL(cfgLogFile(), true, " check logging"); + + // ------------------------------------------------------------------------------------------------------------------------- + TEST_TITLE("version command does not do file logging"); + + TEST_RESULT_VOID(harnessCfgLoad(cfgCmdVersion, strLstNew()), "version command"); + TEST_RESULT_BOOL(cfgLogFile(), false, " check logging"); + + // ------------------------------------------------------------------------------------------------------------------------- + // TEST_TITLE("option key 1 is not required"); + // + // argList = strLstNew(); + // hrnCfgArgRawZ(argList, cfgOptStanza, "test"); + // hrnCfgArgKeyRawZ(argList, cfgOptPgPath, 2, "/pg2"); + // hrnCfgArgKeyRawZ(argList, cfgOptPgPath, 8, "/pg8"); + // TEST_RESULT_VOID(harnessCfgLoad(cfgCmdCheck, argList), "check command"); + // + // TEST_RESULT_STR_Z(cfgOptionIdxStr(cfgOptPgPath, 0), "/pg2", "check pg1-path"); + // TEST_RESULT_STR_Z(cfgOptionIdxStr(cfgOptPgPath, cfgOptionKeyToIdx(cfgOptPgPath, 8)), "/pg8", "check pg8-path"); + + // ------------------------------------------------------------------------------------------------------------------------- + TEST_TITLE("invalid pg option"); + + argList = strLstNew(); + hrnCfgArgRawZ(argList, cfgOptStanza, "test"); + hrnCfgArgKeyRawZ(argList, cfgOptPgPath, 1, "/pg1"); + hrnCfgArgKeyRawZ(argList, cfgOptPgPath, 8, "/pg8"); + hrnCfgArgRawZ(argList, cfgOptPg, "4"); + TEST_ERROR(harnessCfgLoad(cfgCmdCheck, argList), OptionInvalidValueError, "key '4' is not valid for 'pg' option"); } // ***************************************************************************************************************************** diff --git a/test/src/module/db/dbTest.c b/test/src/module/db/dbTest.c index 53b3177c6..bc446456e 100644 --- a/test/src/module/db/dbTest.c +++ b/test/src/module/db/dbTest.c @@ -671,7 +671,7 @@ testRun(void) "P00 WARN: unable to check pg-5: [DbConnectError] raised from remote-0 protocol on 'localhost':" " unable to connect to 'dbname='postgres' port=5432': could not connect to server: [NO SUCH FILE OR DIRECTORY]"); - TEST_RESULT_INT(result.primaryIdx, 7, " check primary id"); + TEST_RESULT_INT(result.primaryIdx, 3, " check primary idx"); TEST_RESULT_BOOL(result.primary != NULL, true, " check primary"); TEST_RESULT_STR_Z(dbArchiveMode(result.primary), "on", " dbArchiveMode"); TEST_RESULT_STR_Z(dbArchiveCommand(result.primary), PROJECT_BIN, " dbArchiveCommand"); diff --git a/test/src/module/performance/storageTest.c b/test/src/module/performance/storageTest.c index 57dfb7a44..d05a28336 100644 --- a/test/src/module/performance/storageTest.c +++ b/test/src/module/performance/storageTest.c @@ -167,7 +167,9 @@ testRun(void) driver.interface.infoList = storageTestPerfInfoList; - storageHelper.storageRepo = storageNew(STRDEF("TEST"), STRDEF("/"), 0, 0, false, NULL, &driver, driver.interface); + storageHelper.storageRepo = memNew(sizeof(Storage *)); + storageHelper.storageRepo[0] = storageNew( + STRDEF("TEST"), STRDEF("/"), 0, 0, false, NULL, &driver, driver.interface); // Setup handler for remote storage protocol IoRead *read = ioFdReadNew(strNew("storage server read"), HARNESS_FORK_CHILD_READ(), 60000); diff --git a/test/src/module/protocol/protocolTest.c b/test/src/module/protocol/protocolTest.c index d7ef63d67..1fdd6e210 100644 --- a/test/src/module/protocol/protocolTest.c +++ b/test/src/module/protocol/protocolTest.c @@ -133,7 +133,7 @@ testRun(void) strLstAddZ(argList, "archive-get"); harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList)); - TEST_RESULT_BOOL(repoIsLocal(), true, "repo is local"); + TEST_RESULT_BOOL(repoIsLocal(0), true, "repo is local"); TEST_RESULT_VOID(repoIsLocalVerify(), " local verified"); // ------------------------------------------------------------------------------------------------------------------------- @@ -145,7 +145,7 @@ testRun(void) strLstAddZ(argList, "archive-get"); harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList)); - TEST_RESULT_BOOL(repoIsLocal(), false, "repo is remote"); + TEST_RESULT_BOOL(repoIsLocal(0), false, "repo is remote"); TEST_ERROR_FMT(repoIsLocalVerify(), HostInvalidError, "archive-get command must be run on the repository host"); // ------------------------------------------------------------------------------------------------------------------------- @@ -185,14 +185,14 @@ testRun(void) hrnCfgArgRawZ(argList, cfgOptPgPath, "/path/to/bogus"); strLstAddZ(argList, "--pg7-path=/path/to"); strLstAddZ(argList, "--pg7-host=test1"); - strLstAddZ(argList, "--host-id=7"); + hrnCfgArgRawZ(argList, cfgOptPg, "7"); strLstAddZ(argList, "--" CFGOPT_REMOTE_TYPE "=" PROTOCOL_REMOTE_TYPE_PG); strLstAddZ(argList, "--process=0"); hrnCfgArgRawZ(argList, cfgOptRepoRetentionFull, "1"); strLstAddZ(argList, CFGCMD_BACKUP ":" CONFIG_COMMAND_ROLE_LOCAL); harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList)); - TEST_RESULT_BOOL(pgIsLocal(6), false, "pg7 is remote"); + TEST_RESULT_BOOL(pgIsLocal(1), false, "pg7 is remote"); } // ***************************************************************************************************************************** @@ -228,8 +228,8 @@ testRun(void) TEST_RESULT_STR_Z( strLstJoin(protocolLocalParam(protocolStorageTypeRepo, 0, 0), "|"), - "--exec-id=1-test|--host-id=1|--log-level-console=off|--log-level-file=off|--log-level-stderr=error" - "|--pg1-path=/path/to/pg|--process=0|--remote-type=repo|--stanza=test1|archive-get:local", + "--exec-id=1-test|--log-level-console=off|--log-level-file=off|--log-level-stderr=error|--pg1-path=/path/to/pg" + "|--process=0|--remote-type=repo|--repo=1|--stanza=test1|archive-get:local", "local repo protocol params"); // ------------------------------------------------------------------------------------------------------------------------- @@ -237,6 +237,7 @@ testRun(void) strLstAddZ(argList, "pgbackrest"); strLstAddZ(argList, "--stanza=test1"); strLstAddZ(argList, "--pg1-path=/pg"); + hrnCfgArgRawReset(argList, cfgOptPg); strLstAddZ(argList, "--repo1-retention-full=1"); strLstAddZ(argList, "--log-subprocess"); strLstAddZ(argList, "backup"); @@ -244,8 +245,8 @@ testRun(void) TEST_RESULT_STR_Z( strLstJoin(protocolLocalParam(protocolStorageTypePg, 0, 1), "|"), - "--exec-id=1-test|--host-id=1|--log-level-console=off|--log-level-file=info|--log-level-stderr=error|--log-subprocess|" - "--pg1-path=/pg|--process=1|--remote-type=pg|--repo1-retention-full=1|--stanza=test1|backup:local", + "--exec-id=1-test|--log-level-console=off|--log-level-file=info|--log-level-stderr=error|--log-subprocess|--pg=1" + "|--pg1-path=/pg|--process=1|--remote-type=pg|--repo1-retention-full=1|--stanza=test1|backup:local", "local pg protocol params"); } @@ -271,7 +272,7 @@ testRun(void) strLstJoin(protocolRemoteParam(protocolStorageTypeRepo, 0), "|"), "-o|LogLevel=error|-o|Compression=no|-o|PasswordAuthentication=no|repo-host-user@repo-host" "|pgbackrest --exec-id=1-test --log-level-console=off --log-level-file=off --log-level-stderr=error" - " --pg1-path=/path/to/pg --process=0 --remote-type=repo --repo1-local --stanza=test1 archive-get:remote", + " --pg1-path=/path/to/pg --process=0 --remote-type=repo --repo=1 --repo1-local --stanza=test1 archive-get:remote", "remote protocol params"); // ------------------------------------------------------------------------------------------------------------------------- @@ -295,7 +296,7 @@ testRun(void) "-o|LogLevel=error|-o|Compression=no|-o|PasswordAuthentication=no|-p|444|repo-host-user@repo-host" "|pgbackrest --config=/path/pgbackrest.conf --config-include-path=/path/include --config-path=/path/config" " --exec-id=1-test --log-level-console=off --log-level-file=info --log-level-stderr=error --log-subprocess" - " --pg1-path=/unused --process=0 --remote-type=repo --repo1-local --stanza=test1 check:remote", + " --pg1-path=/unused --process=0 --remote-type=repo --repo=1 --repo1-local --stanza=test1 check:remote", "remote protocol params with replacements"); // ------------------------------------------------------------------------------------------------------------------------- @@ -304,7 +305,7 @@ testRun(void) strLstAddZ(argList, "--stanza=test1"); hrnCfgArgRawZ(argList, cfgOptPgPath, "/path/to/pg"); strLstAddZ(argList, "--process=3"); - strLstAddZ(argList, "--host-id=1"); + hrnCfgArgRawZ(argList, cfgOptRepo, "1"); strLstAddZ(argList, "--" CFGOPT_REMOTE_TYPE "=" PROTOCOL_REMOTE_TYPE_REPO); strLstAddZ(argList, "--repo1-host=repo-host"); strLstAddZ(argList, CFGCMD_ARCHIVE_GET ":" CONFIG_COMMAND_ROLE_LOCAL); @@ -314,7 +315,7 @@ testRun(void) strLstJoin(protocolRemoteParam(protocolStorageTypeRepo, 0), "|"), "-o|LogLevel=error|-o|Compression=no|-o|PasswordAuthentication=no|pgbackrest@repo-host" "|pgbackrest --exec-id=1-test --log-level-console=off --log-level-file=off --log-level-stderr=error" - " --pg1-path=/path/to/pg --process=3 --remote-type=repo --repo1-local --stanza=test1 archive-get:remote", + " --pg1-path=/path/to/pg --process=3 --remote-type=repo --repo=1 --repo1-local --stanza=test1 archive-get:remote", "remote protocol params for backup local"); // ------------------------------------------------------------------------------------------------------------------------- @@ -330,8 +331,8 @@ testRun(void) TEST_RESULT_STR_Z( strLstJoin(protocolRemoteParam(protocolStorageTypePg, 0), "|"), "-o|LogLevel=error|-o|Compression=no|-o|PasswordAuthentication=no|postgres@pg1-host" - "|pgbackrest --exec-id=1-test --log-level-console=off --log-level-file=off --log-level-stderr=error --pg1-local" - " --pg1-path=/path/to/1 --process=0 --remote-type=pg --stanza=test1 backup:remote", + "|pgbackrest --exec-id=1-test --log-level-console=off --log-level-file=off --log-level-stderr=error --pg=1" + " --pg1-local --pg1-path=/path/to/1 --process=0 --remote-type=pg --stanza=test1 backup:remote", "remote protocol params for db backup"); // ------------------------------------------------------------------------------------------------------------------------- @@ -339,7 +340,7 @@ testRun(void) strLstAddZ(argList, "pgbackrest"); strLstAddZ(argList, "--stanza=test1"); strLstAddZ(argList, "--process=4"); - strLstAddZ(argList, "--host-id=2"); + hrnCfgArgRawZ(argList, cfgOptPg, "2"); strLstAddZ(argList, "--pg1-path=/path/to/1"); strLstAddZ(argList, "--pg1-socket-path=/socket3"); strLstAddZ(argList, "--pg1-port=1111"); @@ -353,8 +354,8 @@ testRun(void) TEST_RESULT_STR_Z( strLstJoin(protocolRemoteParam(protocolStorageTypePg, 1), "|"), "-o|LogLevel=error|-o|Compression=no|-o|PasswordAuthentication=no|postgres@pg2-host" - "|pgbackrest --exec-id=1-test --log-level-console=off --log-level-file=off --log-level-stderr=error --pg1-local" - " --pg1-path=/path/to/2 --process=4 --remote-type=pg --stanza=test1 backup:remote", + "|pgbackrest --exec-id=1-test --log-level-console=off --log-level-file=off --log-level-stderr=error --pg=1" + " --pg1-local --pg1-path=/path/to/2 --process=4 --remote-type=pg --stanza=test1 backup:remote", "remote protocol params for db local"); // ------------------------------------------------------------------------------------------------------------------------- @@ -362,7 +363,7 @@ testRun(void) strLstAddZ(argList, "pgbackrest"); strLstAddZ(argList, "--stanza=test1"); strLstAddZ(argList, "--process=4"); - strLstAddZ(argList, "--host-id=3"); + hrnCfgArgRawZ(argList, cfgOptPg, "3"); strLstAddZ(argList, "--pg1-path=/path/to/1"); strLstAddZ(argList, "--pg3-path=/path/to/3"); strLstAddZ(argList, "--pg3-host=pg3-host"); @@ -374,11 +375,11 @@ testRun(void) harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList)); TEST_RESULT_STR_Z( - strLstJoin(protocolRemoteParam(protocolStorageTypePg, 2), "|"), + strLstJoin(protocolRemoteParam(protocolStorageTypePg, 1), "|"), "-o|LogLevel=error|-o|Compression=no|-o|PasswordAuthentication=no|postgres@pg3-host" - "|pgbackrest --exec-id=1-test --log-level-console=off --log-level-file=off --log-level-stderr=error --pg1-local" - " --pg1-path=/path/to/3 --pg1-port=3333 --pg1-socket-path=/socket3 --process=4 --remote-type=pg --stanza=test1" - " backup:remote", + "|pgbackrest --exec-id=1-test --log-level-console=off --log-level-file=off --log-level-stderr=error --pg=1" + " --pg1-local --pg1-path=/path/to/3 --pg1-port=3333 --pg1-socket-path=/socket3 --process=4 --remote-type=pg" + " --stanza=test1 backup:remote", "remote protocol params for db local"); } @@ -978,7 +979,7 @@ testRun(void) strLstAdd(argList, strNewFmt("--repo1-host-user=%s", testUser())); strLstAdd(argList, strNewFmt("--repo1-path=%s", testPath())); strLstAddZ(argList, "--process=999"); - strLstAddZ(argList, "--host-id=1"); + hrnCfgArgRawZ(argList, cfgOptPg, "1"); strLstAddZ(argList, "--" CFGOPT_REMOTE_TYPE "=" PROTOCOL_REMOTE_TYPE_PG); harnessCfgLoadRole(cfgCmdArchiveGet, cfgCmdRoleLocal, argList); diff --git a/test/src/module/storage/azureTest.c b/test/src/module/storage/azureTest.c index 2ad9ee4c5..308f6ff71 100644 --- a/test/src/module/storage/azureTest.c +++ b/test/src/module/storage/azureTest.c @@ -190,7 +190,7 @@ testRun(void) harnessCfgLoad(cfgCmdArchivePush, argList); Storage *storage = NULL; - TEST_ASSIGN(storage, storageRepoGet(strNew(STORAGE_AZURE_TYPE), false), "get repo storage"); + TEST_ASSIGN(storage, storageRepoGet(0, false), "get repo storage"); TEST_RESULT_STR_Z(storage->path, "/repo", " check path"); TEST_RESULT_STR(((StorageAzure *)storage->driver)->account, TEST_ACCOUNT_STR, " check account"); TEST_RESULT_STR(((StorageAzure *)storage->driver)->container, TEST_CONTAINER_STR, " check container"); @@ -299,7 +299,7 @@ testRun(void) harnessCfgLoad(cfgCmdArchivePush, argList); Storage *storage = NULL; - TEST_ASSIGN(storage, storageRepoGet(strNew(STORAGE_AZURE_TYPE), true), "get repo storage"); + TEST_ASSIGN(storage, storageRepoGet(0, true), "get repo storage"); driver = (StorageAzure *)storage->driver; TEST_RESULT_STR(driver->host, hrnServerHost(), " check host"); @@ -731,7 +731,7 @@ testRun(void) hrnCfgEnvRawZ(cfgOptRepoAzureKey, TEST_KEY_SAS); harnessCfgLoad(cfgCmdArchivePush, argList); - TEST_ASSIGN(storage, storageRepoGet(strNew(STORAGE_AZURE_TYPE), true), "get repo storage"); + TEST_ASSIGN(storage, storageRepoGet(0, true), "get repo storage"); driver = (StorageAzure *)storage->driver; TEST_RESULT_PTR_NE(driver->sasKey, NULL, "check sas key"); diff --git a/test/src/module/storage/cifsTest.c b/test/src/module/storage/cifsTest.c index 52afa9fd0..4da962bee 100644 --- a/test/src/module/storage/cifsTest.c +++ b/test/src/module/storage/cifsTest.c @@ -23,7 +23,7 @@ testRun(void) harnessCfgLoad(cfgCmdArchiveGet, argList); const Storage *storage = NULL; - TEST_ASSIGN(storage, storageRepoGet(strNew(STORAGE_CIFS_TYPE), true), "get cifs repo storage"); + TEST_ASSIGN(storage, storageRepoGet(0, true), "get cifs repo storage"); TEST_RESULT_STR_Z(storage->type, "cifs", "check storage type"); TEST_RESULT_BOOL(storageFeature(storage, storageFeaturePath), true, " check path feature"); TEST_RESULT_BOOL(storageFeature(storage, storageFeatureCompress), true, " check compress feature"); diff --git a/test/src/module/storage/posixTest.c b/test/src/module/storage/posixTest.c index 2ba23635a..2843f524f 100644 --- a/test/src/module/storage/posixTest.c +++ b/test/src/module/storage/posixTest.c @@ -69,7 +69,7 @@ testRun(void) TEST_TITLE("writable storage fails when dry-run is not initialized"); TEST_ERROR(storagePgIdxWrite(0), AssertError, WRITABLE_WHILE_DRYRUN); - TEST_ERROR(storageRepoWrite(), AssertError, WRITABLE_WHILE_DRYRUN); + TEST_ERROR(storageRepoIdxWrite(0), AssertError, WRITABLE_WHILE_DRYRUN); TEST_ERROR(storageSpoolWrite(), AssertError, WRITABLE_WHILE_DRYRUN); // ------------------------------------------------------------------------------------------------------------------------- @@ -78,7 +78,7 @@ testRun(void) storageHelperDryRunInit(true); TEST_ERROR(storagePgIdxWrite(0), AssertError, WRITABLE_WHILE_DRYRUN); - TEST_ERROR(storageRepoWrite(), AssertError, WRITABLE_WHILE_DRYRUN); + TEST_ERROR(storageRepoIdxWrite(0), AssertError, WRITABLE_WHILE_DRYRUN); TEST_ERROR(storageSpoolWrite(), AssertError, WRITABLE_WHILE_DRYRUN); } @@ -1163,14 +1163,11 @@ testRun(void) strLstAdd(argList, strNewFmt("--repo-path=%s", testPath())); harnessCfgLoad(cfgCmdArchiveGet, argList); - TEST_ERROR(storageRepoGet(strNew(BOGUS_STR), false), AssertError, "invalid storage type 'BOGUS'"); - - // ------------------------------------------------------------------------------------------------------------------------- const Storage *storage = NULL; TEST_RESULT_PTR(storageHelper.storageRepo, NULL, "repo storage not cached"); TEST_ASSIGN(storage, storageRepo(), "new storage"); - TEST_RESULT_PTR(storageHelper.storageRepo, storage, "repo storage cached"); + TEST_RESULT_PTR(storageHelper.storageRepo[0], storage, "repo storage cached"); TEST_RESULT_PTR(storageRepo(), storage, "get cached storage"); // ------------------------------------------------------------------------------------------------------------------------- @@ -1221,7 +1218,7 @@ testRun(void) // ------------------------------------------------------------------------------------------------------------------------- TEST_RESULT_PTR(storageHelper.storageRepoWrite, NULL, "repo write storage not cached"); TEST_ASSIGN(storage, storageRepoWrite(), "new write storage"); - TEST_RESULT_PTR(storageHelper.storageRepoWrite, storage, "repo write storage cached"); + TEST_RESULT_PTR(storageHelper.storageRepoWrite[0], storage, "repo write storage cached"); TEST_RESULT_PTR(storageRepoWrite(), storage, "get cached storage"); TEST_RESULT_BOOL(storage->write, true, "get write enabled"); diff --git a/test/src/module/storage/remoteTest.c b/test/src/module/storage/remoteTest.c index a8639b2a8..47ae0c097 100644 --- a/test/src/module/storage/remoteTest.c +++ b/test/src/module/storage/remoteTest.c @@ -57,7 +57,7 @@ testRun(void) if (testBegin("storageNew()")) { Storage *storageRemote = NULL; - TEST_ASSIGN(storageRemote, storageRepoGet(strNew(STORAGE_POSIX_TYPE), false), "get remote repo storage"); + TEST_ASSIGN(storageRemote, storageRepoGet(0, false), "get remote repo storage"); TEST_RESULT_UINT(storageInterface(storageRemote).feature, storageInterface(storageTest).feature, " check features"); TEST_RESULT_BOOL(storageFeature(storageRemote, storageFeaturePath), true, " check path feature"); TEST_RESULT_BOOL(storageFeature(storageRemote, storageFeatureCompress), true, " check compress feature"); @@ -83,7 +83,7 @@ testRun(void) if (testBegin("storageInfo()")) { Storage *storageRemote = NULL; - TEST_ASSIGN(storageRemote, storageRepoGet(strNew(STORAGE_POSIX_TYPE), true), "get remote repo storage"); + TEST_ASSIGN(storageRemote, storageRepoGet(0, true), "get remote repo storage"); // ------------------------------------------------------------------------------------------------------------------------- TEST_TITLE("missing file/path"); @@ -253,7 +253,7 @@ testRun(void) if (testBegin("storageInfoList()")) { Storage *storageRemote = NULL; - TEST_ASSIGN(storageRemote, storageRepoGet(strNew(STORAGE_POSIX_TYPE), true), "get remote repo storage"); + TEST_ASSIGN(storageRemote, storageRepoGet(0, true), "get remote repo storage"); // ------------------------------------------------------------------------------------------------------------------------- TEST_TITLE("path not found"); @@ -314,7 +314,7 @@ testRun(void) if (testBegin("storageNewRead()")) { Storage *storageRemote = NULL; - TEST_ASSIGN(storageRemote, storageRepoGet(strNew(STORAGE_POSIX_TYPE), false), "get remote repo storage"); + TEST_ASSIGN(storageRemote, storageRepoGet(0, false), "get remote repo storage"); storagePathCreateP(storageTest, strNew("repo")); Buffer *contentBuf = bufNew(32768); @@ -463,7 +463,7 @@ testRun(void) storagePathCreateP(storageTest, strNew("repo")); Storage *storageRemote = NULL; - TEST_ASSIGN(storageRemote, storageRepoGet(strNew(STORAGE_POSIX_TYPE), true), "get remote repo storage"); + TEST_ASSIGN(storageRemote, storageRepoGet(0, true), "get remote repo storage"); // Create buffer with plenty of data Buffer *contentBuf = bufNew(32768); @@ -603,7 +603,7 @@ testRun(void) storagePathCreateP(storageTest, strNew("repo")); Storage *storageRemote = NULL; - TEST_ASSIGN(storageRemote, storageRepoGet(strNew(STORAGE_POSIX_TYPE), true), "get remote repo storage"); + TEST_ASSIGN(storageRemote, storageRepoGet(0, true), "get remote repo storage"); // Create a path via the remote. Check the repo via the local test storage to ensure the remote created it. TEST_RESULT_VOID(storagePathCreateP(storageRemote, path), "new path"); @@ -661,7 +661,7 @@ testRun(void) storagePathCreateP(storageTest, strNew("repo")); Storage *storageRemote = NULL; - TEST_ASSIGN(storageRemote, storageRepoGet(strNew(STORAGE_POSIX_TYPE), true), "get remote repo storage"); + TEST_ASSIGN(storageRemote, storageRepoGet(0, true), "get remote repo storage"); TEST_RESULT_VOID(storagePathCreateP(storageRemote, path), "new path"); // Check the repo via the local test storage to ensure the remote wrote it, then remove via the remote and confirm removed @@ -701,7 +701,7 @@ testRun(void) storagePathCreateP(storageTest, strNew("repo")); Storage *storageRemote = NULL; - TEST_ASSIGN(storageRemote, storageRepoGet(strNew(STORAGE_POSIX_TYPE), true), "get remote repo storage"); + TEST_ASSIGN(storageRemote, storageRepoGet(0, true), "get remote repo storage"); String *file = strNew("file.txt"); // Write the file to the repo via the remote so owner is pgbackrest @@ -749,7 +749,7 @@ testRun(void) storagePathCreateP(storageTest, strNew("repo")); Storage *storageRemote = NULL; - TEST_ASSIGN(storageRemote, storageRepoGet(strNew(STORAGE_POSIX_TYPE), true), "get remote repo storage"); + TEST_ASSIGN(storageRemote, storageRepoGet(0, true), "get remote repo storage"); String *path = strNew("testpath"); TEST_RESULT_VOID(storagePathCreateP(storageRemote, path), "new path"); diff --git a/test/src/module/storage/s3Test.c b/test/src/module/storage/s3Test.c index fbcf40a8c..c77924000 100644 --- a/test/src/module/storage/s3Test.c +++ b/test/src/module/storage/s3Test.c @@ -257,7 +257,7 @@ testRun(void) StringList *argList = strLstDup(commonArgList); harnessCfgLoad(cfgCmdArchivePush, argList); - StorageS3 *driver = (StorageS3 *)storageDriver(storageRepoGet(STORAGE_S3_TYPE_STR, false)); + StorageS3 *driver = (StorageS3 *)storageDriver(storageRepoGet(0, false)); TEST_RESULT_STR(driver->bucket, bucket, "check bucket"); TEST_RESULT_STR(driver->region, region, "check region"); @@ -328,7 +328,7 @@ testRun(void) hrnCfgEnvRaw(cfgOptRepoS3Token, securityToken); harnessCfgLoad(cfgCmdArchivePush, argList); - driver = (StorageS3 *)storageDriver(storageRepoGet(STORAGE_S3_TYPE_STR, false)); + driver = (StorageS3 *)storageDriver(storageRepoGet(0, false)); TEST_RESULT_STR(driver->securityToken, securityToken, "check security token"); TEST_RESULT_STR( @@ -392,7 +392,7 @@ testRun(void) hrnCfgEnvRaw(cfgOptRepoS3Token, securityToken); harnessCfgLoad(cfgCmdArchivePush, argList); - Storage *s3 = storageRepoGet(STORAGE_S3_TYPE_STR, true); + Storage *s3 = storageRepoGet(0, true); StorageS3 *driver = (StorageS3 *)s3->driver; TEST_RESULT_STR(s3->path, path, "check path"); @@ -450,7 +450,7 @@ testRun(void) hrnCfgArgRawZ(argList, cfgOptRepoS3KeyType, STORAGE_S3_KEY_TYPE_AUTO); harnessCfgLoad(cfgCmdArchivePush, argList); - s3 = storageRepoGet(STORAGE_S3_TYPE_STR, true); + s3 = storageRepoGet(0, true); driver = (StorageS3 *)s3->driver; TEST_RESULT_STR(s3->path, path, "check path"); @@ -1019,7 +1019,7 @@ testRun(void) hrnCfgEnvRemoveRaw(cfgOptRepoS3Token); harnessCfgLoad(cfgCmdArchivePush, argList); - s3 = storageRepoGet(STORAGE_S3_TYPE_STR, true); + s3 = storageRepoGet(0, true); driver = (StorageS3 *)s3->driver; // Set deleteMax to a small value for testing