diff --git a/build/lib/pgBackRestBuild/Config/Build.pm b/build/lib/pgBackRestBuild/Config/Build.pm index a67512f19..10a1f805e 100644 --- a/build/lib/pgBackRestBuild/Config/Build.pm +++ b/build/lib/pgBackRestBuild/Config/Build.pm @@ -32,6 +32,7 @@ use constant BLDLCL_CONSTANT_OPTION_GROUP => '02-const use constant BLDLCL_CONSTANT_OPTION_GROUP_TOTAL => 'CFG_OPTION_GROUP_TOTAL'; use constant BLDLCL_CONSTANT_OPTION => '03-constantOption'; use constant BLDLCL_CONSTANT_OPTION_TOTAL => 'CFG_OPTION_TOTAL'; +use constant BLDLCL_CONSTANT_OPTION_VALUE => '04-constantOptionValue'; use constant BLDLCL_DATA_COMMAND_CONSTANT => '01-commandConstant'; use constant BLDLCL_DATA_COMMAND => '02-command'; @@ -66,6 +67,10 @@ my $rhBuild = { &BLD_SUMMARY => 'Option', }, + &BLDLCL_CONSTANT_OPTION_VALUE => + { + &BLD_SUMMARY => 'Option value', + }, }, &BLD_ENUM => @@ -258,6 +263,66 @@ sub buildConfig $rhBuild->{&BLD_FILE}{&BLDLCL_FILE_CONFIG}{&BLD_CONSTANT_GROUP}{&BLDLCL_CONSTANT_OPTION}{&BLD_CONSTANT} {&BLDLCL_CONSTANT_OPTION_TOTAL}{&BLD_CONSTANT_VALUE} = $iOptionTotal; + # Build option value constants + #------------------------------------------------------------------------------------------------------------------------------- + my $rhLastConstant = undef; + + foreach my $strOption (sort(keys(%{$rhConfigDefine}))) + { + my $rhOption = $rhConfigDefine->{$strOption}; + + # Only output allowed values for string options + if ($rhOption->{&CFGDEF_TYPE} eq CFGDEF_TYPE_STRING) + { + # Add LF to last option value list so they are not all jumbled together + if (defined($rhLastConstant)) + { + $rhLastConstant->{&BLD_CONSTANT_VALUE} .= "\n"; + $rhLastConstant = undef; + } + + # Add allowed values for the option, if any + my $rhValueHash = {}; + + if (defined($rhOption->{&CFGDEF_ALLOW_LIST})) + { + foreach my $strValue (sort(@{$rhOption->{&CFGDEF_ALLOW_LIST}})) + { + $rhValueHash->{$strValue} = true; + } + } + + # Add allowed values for the option commands, if any + foreach my $strCommand (sort(keys(%{$rhOption->{&CFGDEF_COMMAND}}))) + { + my $rhOptionCommand = $rhOption->{&CFGDEF_COMMAND}{$strCommand}; + + if (defined($rhOptionCommand->{&CFGDEF_ALLOW_LIST})) + { + foreach my $strValue (sort(@{$rhOptionCommand->{&CFGDEF_ALLOW_LIST}})) + { + $rhValueHash->{$strValue} = true; + } + } + } + + # Output list of allowed values + foreach my $strValue (sort(keys(%{$rhValueHash}))) + { + my $strOptionValueConst = 'CFGOPTVAL_' . uc($strOption) . '_' . uc($strValue) . '_Z'; + $strOptionValueConst =~ s/\-/_/g; + + $rhBuild->{&BLD_FILE}{&BLDLCL_FILE_CONFIG}{&BLD_CONSTANT_GROUP}{&BLDLCL_CONSTANT_OPTION_VALUE}{&BLD_CONSTANT} + {$strOptionValueConst}{&BLD_CONSTANT_VALUE} = "\"${strValue}\""; + + # Save last constant so an LF can be added later, if needed + $rhLastConstant = + $rhBuild->{&BLD_FILE}{&BLDLCL_FILE_CONFIG}{&BLD_CONSTANT_GROUP}{&BLDLCL_CONSTANT_OPTION_VALUE}{&BLD_CONSTANT} + {$strOptionValueConst}; + } + } + } + return $rhBuild; } diff --git a/doc/xml/release.xml b/doc/xml/release.xml index 43016a082..75de17eb0 100644 --- a/doc/xml/release.xml +++ b/doc/xml/release.xml @@ -102,6 +102,9 @@ + + + diff --git a/src/command/expire/expire.c b/src/command/expire/expire.c index 9b1f8756c..58c1587c5 100644 --- a/src/command/expire/expire.c +++ b/src/command/expire/expire.c @@ -911,8 +911,8 @@ cmdExpire(void) const Storage *storageRepo = storageRepoIdx(repoIdx); InfoBackup *infoBackup = NULL; - bool timeBasedFullRetention = strEqZ( - cfgOptionIdxStr(cfgOptRepoRetentionFullType, repoIdx), CFGOPTVAL_TMP_REPO_RETENTION_FULL_TYPE_TIME); + bool timeBasedFullRetention = + cfgOptionIdxStrId(cfgOptRepoRetentionFullType, repoIdx) == CFGOPTVAL_REPO_RETENTION_FULL_TYPE_TIME; TRY_BEGIN() { diff --git a/src/command/info/info.c b/src/command/info/info.c index 4ca8aadd5..df2094a5e 100644 --- a/src/command/info/info.c +++ b/src/command/info/info.c @@ -29,8 +29,6 @@ Info Command /*********************************************************************************************************************************** Constants ***********************************************************************************************************************************/ -STRING_STATIC(CFGOPTVAL_INFO_OUTPUT_TEXT_STR, "text"); - // Naming convention: _KEY__VAR. If the key exists in multiple sections, then _ is omitted. VARIANT_STRDEF_STATIC(ARCHIVE_KEY_MIN_VAR, "min"); VARIANT_STRDEF_STATIC(ARCHIVE_KEY_MAX_VAR, "max"); @@ -1207,8 +1205,8 @@ infoRender(void) // Since the --set option depends on the --stanza option, the parser will error before this if the backup label is // specified but a stanza is not - if (backupLabel != NULL && !strEq(cfgOptionStr(cfgOptOutput), CFGOPTVAL_INFO_OUTPUT_TEXT_STR)) - THROW(ConfigError, "option '" CFGOPT_SET "' is currently only valid for text output"); + if (backupLabel != NULL && cfgOptionStrId(cfgOptOutput) != CFGOPTVAL_OUTPUT_TEXT) + THROW(ConfigError, "option '" CFGOPT_SET "' is currently only valid for " CFGOPTVAL_OUTPUT_TEXT_Z " output"); // Initialize the repo index unsigned int repoIdxMin = 0; @@ -1387,7 +1385,7 @@ infoRender(void) infoList = stanzaInfoList(stanzaRepoList, backupLabel, repoIdxMin, repoIdxMax); // Format text output - if (strEq(cfgOptionStr(cfgOptOutput), CFGOPTVAL_INFO_OUTPUT_TEXT_STR)) + if (cfgOptionStrId(cfgOptOutput) == CFGOPTVAL_OUTPUT_TEXT) { // Process any stanza directories if (!varLstEmpty(infoList)) @@ -1519,7 +1517,10 @@ infoRender(void) } // Format json output else + { + ASSERT(cfgOptionStrId(cfgOptOutput) == CFGOPTVAL_OUTPUT_JSON); resultStr = jsonFromVar(varNewVarLst(infoList)); + } MEM_CONTEXT_PRIOR_BEGIN() { diff --git a/src/command/repo/ls.c b/src/command/repo/ls.c index 6489a8bd0..9fa3b9375 100644 --- a/src/command/repo/ls.c +++ b/src/command/repo/ls.c @@ -107,12 +107,18 @@ storageListRender(IoWrite *write) // Get sort order SortOrder sortOrder = sortOrderAsc; - if (strEqZ(cfgOptionStr(cfgOptSort), "desc")) - sortOrder = sortOrderDesc; - else if (!strEqZ(cfgOptionStr(cfgOptSort), "asc")) + switch (cfgOptionStrId(cfgOptSort)) { - ASSERT(strEqZ(cfgOptionStr(cfgOptSort), "none")); - sortOrder = sortOrderNone; + case CFGOPTVAL_SORT_DESC: + sortOrder = sortOrderDesc; + break; + + case CFGOPTVAL_SORT_NONE: + sortOrder = sortOrderNone; + break; + + default: + ASSERT(cfgOptionStrId(cfgOptSort) == CFGOPTVAL_SORT_ASC); } // Get path @@ -124,7 +130,7 @@ storageListRender(IoWrite *write) THROW(ParamInvalidError, "only one path may be specified"); // Get options - bool json = strEqZ(cfgOptionStr(cfgOptOutput), "json") ? true : false; + bool json = cfgOptionStrId(cfgOptOutput) == CFGOPTVAL_OUTPUT_JSON ? true : false; const String *expression = cfgOptionStrNull(cfgOptFilter); RegExp *regExp = expression == NULL ? NULL : regExpNew(expression); diff --git a/src/command/restore/restore.c b/src/command/restore/restore.c index 36197bd95..4d3b6edf8 100644 --- a/src/command/restore/restore.c +++ b/src/command/restore/restore.c @@ -40,10 +40,6 @@ Recovery constants #define RECOVERY_TARGET_XID "recovery_target_xid" #define RECOVERY_TARGET_ACTION "recovery_target_action" -#define RECOVERY_TARGET_ACTION_PAUSE "pause" - STRING_STATIC(RECOVERY_TARGET_ACTION_PAUSE_STR, RECOVERY_TARGET_ACTION_PAUSE); -#define RECOVERY_TARGET_ACTION_SHUTDOWN "shutdown" - STRING_STATIC(RECOVERY_TARGET_ACTION_SHUTDOWN_STR, RECOVERY_TARGET_ACTION_SHUTDOWN); #define RECOVERY_TARGET_INCLUSIVE "recovery_target_inclusive" #define RECOVERY_TARGET_TIMELINE "recovery_target_timeline" @@ -51,23 +47,7 @@ Recovery constants #define STANDBY_MODE "standby_mode" STRING_STATIC(STANDBY_MODE_STR, STANDBY_MODE); -#define RECOVERY_TYPE_DEFAULT "default" - STRING_STATIC(RECOVERY_TYPE_DEFAULT_STR, RECOVERY_TYPE_DEFAULT); -#define RECOVERY_TYPE_IMMEDIATE "immediate" - STRING_STATIC(RECOVERY_TYPE_IMMEDIATE_STR, RECOVERY_TYPE_IMMEDIATE); -#define RECOVERY_TYPE_NONE "none" - STRING_STATIC(RECOVERY_TYPE_NONE_STR, RECOVERY_TYPE_NONE); -#define RECOVERY_TYPE_PRESERVE "preserve" - STRING_STATIC(RECOVERY_TYPE_PRESERVE_STR, RECOVERY_TYPE_PRESERVE); -#define RECOVERY_TYPE_STANDBY "standby" - STRING_STATIC(RECOVERY_TYPE_STANDBY_STR, RECOVERY_TYPE_STANDBY); -#define RECOVERY_TYPE_TIME "time" - STRING_STATIC(RECOVERY_TYPE_TIME_STR, RECOVERY_TYPE_TIME); - #define ARCHIVE_MODE "archive_mode" -#define ARCHIVE_MODE_OFF "off" - STRING_STATIC(ARCHIVE_MODE_OFF_STR, ARCHIVE_MODE_OFF); -STRING_STATIC(ARCHIVE_MODE_PRESERVE_STR, "preserve"); /*********************************************************************************************************************************** Validate restore path @@ -270,7 +250,7 @@ restoreBackupSet(void) // set that satisfies the time condition, else we will use the backup provided if (cfgOptionSource(cfgOptSet) == cfgSourceDefault) { - if (strEq(cfgOptionStr(cfgOptType), RECOVERY_TYPE_TIME_STR)) + if (cfgOptionStrId(cfgOptType) == CFGOPTVAL_TYPE_TIME) timeTargetEpoch = getEpoch(cfgOptionStr(cfgOptTarget)); } else @@ -1023,7 +1003,7 @@ restoreCleanBuild(Manifest *manifest) strLstAdd(cleanData->fileIgnore, BACKUP_MANIFEST_FILE_STR); // Also ignore recovery files when recovery type = preserve - if (strEq(cfgOptionStr(cfgOptType), RECOVERY_TYPE_PRESERVE_STR)) + if (cfgOptionStrId(cfgOptType) == CFGOPTVAL_TYPE_PRESERVE) { // If recovery GUCs then three files must be preserved if (manifestData(manifest)->pgVersion >= PG_VERSION_RECOVERY_GUC) @@ -1119,8 +1099,7 @@ restoreCleanBuild(Manifest *manifest) } // Skip postgresql.auto.conf if preserve is set and the PostgreSQL version supports recovery GUCs - if (manifestData(manifest)->pgVersion >= PG_VERSION_RECOVERY_GUC && - strEq(cfgOptionStr(cfgOptType), RECOVERY_TYPE_PRESERVE_STR) && + if (manifestData(manifest)->pgVersion >= PG_VERSION_RECOVERY_GUC && cfgOptionStrId(cfgOptType) == CFGOPTVAL_TYPE_PRESERVE && manifestFileFindDefault(manifest, STRDEF(MANIFEST_TARGET_PGDATA "/" PG_FILE_POSTGRESQLAUTOCONF), NULL) != NULL) { LOG_DETAIL_FMT("skip '" PG_FILE_POSTGRESQLAUTOCONF "' -- recovery type is preserve"); @@ -1513,9 +1492,7 @@ restoreRecoveryOption(unsigned int pgVersion) } // If archive-mode is not preserve - const String *archiveMode = cfgOptionStr(cfgOptArchiveMode); - - if (!strEq(archiveMode, ARCHIVE_MODE_PRESERVE_STR)) + if (cfgOptionStrId(cfgOptArchiveMode) != CFGOPTVAL_ARCHIVE_MODE_PRESERVE) { if (pgVersion < PG_VERSION_12) { @@ -1526,10 +1503,10 @@ restoreRecoveryOption(unsigned int pgVersion) } // The only other valid option is off - ASSERT(strEq(archiveMode, ARCHIVE_MODE_OFF_STR)); + ASSERT(cfgOptionStrId(cfgOptArchiveMode) == CFGOPTVAL_ARCHIVE_MODE_OFF); // If archive-mode=off then set archive_mode=off - kvPut(result, VARSTRDEF(ARCHIVE_MODE), VARSTR(ARCHIVE_MODE_OFF_STR)); + kvPut(result, VARSTRDEF(ARCHIVE_MODE), VARSTRDEF(CFGOPTVAL_ARCHIVE_MODE_OFF_Z)); } // Write restore_command @@ -1559,19 +1536,19 @@ restoreRecoveryOption(unsigned int pgVersion) } // If recovery type is immediate - if (strEq(cfgOptionStr(cfgOptType), RECOVERY_TYPE_IMMEDIATE_STR)) + if (cfgOptionStrId(cfgOptType) == CFGOPTVAL_TYPE_IMMEDIATE) { - kvPut(result, VARSTRZ(RECOVERY_TARGET), VARSTRZ(RECOVERY_TYPE_IMMEDIATE)); + kvPut(result, VARSTRZ(RECOVERY_TARGET), VARSTRZ(CFGOPTVAL_TYPE_IMMEDIATE_Z)); } // Else recovery type is standby - else if (strEq(cfgOptionStr(cfgOptType), RECOVERY_TYPE_STANDBY_STR)) + else if (cfgOptionStrId(cfgOptType) == CFGOPTVAL_TYPE_STANDBY) { // Write standby_mode for PostgreSQL versions that support it if (pgVersion < PG_VERSION_RECOVERY_GUC) kvPut(result, VARSTR(STANDBY_MODE_STR), VARSTRDEF("on")); } // Else recovery type is not default so write target options - else if (!strEq(cfgOptionStr(cfgOptType), RECOVERY_TYPE_DEFAULT_STR)) + else if (cfgOptionStrId(cfgOptType) != CFGOPTVAL_TYPE_DEFAULT) { // Write the recovery target kvPut( @@ -1586,24 +1563,24 @@ restoreRecoveryOption(unsigned int pgVersion) // Write pause_at_recovery_target/recovery_target_action if (cfgOptionTest(cfgOptTargetAction)) { - const String *targetAction = cfgOptionStr(cfgOptTargetAction); + StringId targetAction = cfgOptionStrId(cfgOptTargetAction); - if (!strEq(targetAction, RECOVERY_TARGET_ACTION_PAUSE_STR)) + if (targetAction != CFGOPTVAL_TARGET_ACTION_PAUSE) { // Write recovery_target on supported PostgreSQL versions if (pgVersion >= PG_VERSION_RECOVERY_TARGET_ACTION) { - kvPut(result, VARSTRZ(RECOVERY_TARGET_ACTION), VARSTR(targetAction)); + kvPut(result, VARSTRZ(RECOVERY_TARGET_ACTION), VARSTR(strIdToStr(targetAction))); } // Write pause_at_recovery_target on supported PostgreSQL versions else if (pgVersion >= PG_VERSION_RECOVERY_TARGET_PAUSE) { // Shutdown action is not supported with pause_at_recovery_target setting - if (strEq(targetAction, RECOVERY_TARGET_ACTION_SHUTDOWN_STR)) + if (targetAction == CFGOPTVAL_TARGET_ACTION_SHUTDOWN) { THROW_FMT( OptionInvalidError, - CFGOPT_TARGET_ACTION "=" RECOVERY_TARGET_ACTION_SHUTDOWN " is only available in PostgreSQL >= %s", + CFGOPT_TARGET_ACTION "=" CFGOPTVAL_TARGET_ACTION_SHUTDOWN_Z " is only available in PostgreSQL >= %s", strZ(pgVersionToStr(PG_VERSION_RECOVERY_TARGET_ACTION))); } @@ -1679,7 +1656,7 @@ restoreRecoveryWriteConf(const Manifest *manifest, unsigned int pgVersion, const FUNCTION_LOG_END(); // Only write recovery.conf if recovery type != none - if (!strEq(cfgOptionStr(cfgOptType), RECOVERY_TYPE_NONE_STR)) + if (cfgOptionStrId(cfgOptType) != CFGOPTVAL_TYPE_NONE) { LOG_INFO_FMT("write %s", strZ(storagePathP(storagePg(), PG_FILE_RECOVERYCONF_STR))); @@ -1751,7 +1728,7 @@ restoreRecoveryWriteAutoConf(unsigned int pgVersion, const String *restoreLabel) } // If settings will be appended then format the file so a blank line will be between old and new settings - if (!strEq(cfgOptionStr(cfgOptType), RECOVERY_TYPE_NONE_STR)) + if (cfgOptionStrId(cfgOptType) != CFGOPTVAL_TYPE_NONE) { strTrim(content); strCatZ(content, "\n\n"); @@ -1759,7 +1736,7 @@ restoreRecoveryWriteAutoConf(unsigned int pgVersion, const String *restoreLabel) } // If recovery was requested then write the recovery options - if (!strEq(cfgOptionStr(cfgOptType), RECOVERY_TYPE_NONE_STR)) + if (cfgOptionStrId(cfgOptType) != CFGOPTVAL_TYPE_NONE) { // If the user specified standby_mode as a recovery option then error. It's tempting to just set type=standby in this // case but since config parsing has already happened the target options could be in an invalid state. @@ -1781,7 +1758,7 @@ restoreRecoveryWriteAutoConf(unsigned int pgVersion, const String *restoreLabel) THROW_FMT( OptionInvalidError, "'" STANDBY_MODE "' setting is not valid for " PG_NAME " >= %s\n" - "HINT: use --" CFGOPT_TYPE "=" RECOVERY_TYPE_STANDBY " instead of --" CFGOPT_RECOVERY_OPTION "=" + "HINT: use --" CFGOPT_TYPE "=" CFGOPTVAL_TYPE_STANDBY_Z " instead of --" CFGOPT_RECOVERY_OPTION "=" STANDBY_MODE "=on.", strZ(pgVersionToStr(PG_VERSION_RECOVERY_GUC))); } @@ -1806,7 +1783,7 @@ restoreRecoveryWriteAutoConf(unsigned int pgVersion, const String *restoreLabel) BUFSTR(content)); // The standby.signal file is required for standby mode - if (strEq(cfgOptionStr(cfgOptType), RECOVERY_TYPE_STANDBY_STR)) + if (cfgOptionStrId(cfgOptType) == CFGOPTVAL_TYPE_STANDBY) { storagePutP( storageNewWriteP( @@ -1842,7 +1819,7 @@ restoreRecoveryWrite(const Manifest *manifest) MEM_CONTEXT_TEMP_BEGIN() { // If recovery type is preserve then leave recovery file as it is - if (strEq(cfgOptionStr(cfgOptType), RECOVERY_TYPE_PRESERVE_STR)) + if (cfgOptionStrId(cfgOptType) == CFGOPTVAL_TYPE_PRESERVE) { // Determine which file recovery setttings will be written to const String *recoveryFile = pgVersion >= PG_VERSION_RECOVERY_GUC ? @@ -1851,7 +1828,7 @@ restoreRecoveryWrite(const Manifest *manifest) if (!storageExistsP(storagePg(), recoveryFile)) { LOG_WARN_FMT( - "recovery type is " RECOVERY_TYPE_PRESERVE " but recovery file does not exist at '%s'", + "recovery type is " CFGOPTVAL_TYPE_PRESERVE_Z " but recovery file does not exist at '%s'", strZ(storagePathP(storagePg(), recoveryFile))); } } diff --git a/src/config/config.auto.h b/src/config/config.auto.h index 2e570394b..b05370f65 100644 --- a/src/config/config.auto.h +++ b/src/config/config.auto.h @@ -139,6 +139,96 @@ Option constants #define CFG_OPTION_TOTAL 130 +/*********************************************************************************************************************************** +Option value constants +***********************************************************************************************************************************/ +#define CFGOPTVAL_ARCHIVE_MODE_OFF_Z "off" +#define CFGOPTVAL_ARCHIVE_MODE_PRESERVE_Z "preserve" + +#define CFGOPTVAL_COMPRESS_TYPE_BZ2_Z "bz2" +#define CFGOPTVAL_COMPRESS_TYPE_GZ_Z "gz" +#define CFGOPTVAL_COMPRESS_TYPE_LZ4_Z "lz4" +#define CFGOPTVAL_COMPRESS_TYPE_NONE_Z "none" +#define CFGOPTVAL_COMPRESS_TYPE_ZST_Z "zst" + +#define CFGOPTVAL_LOG_LEVEL_CONSOLE_DEBUG_Z "debug" +#define CFGOPTVAL_LOG_LEVEL_CONSOLE_DETAIL_Z "detail" +#define CFGOPTVAL_LOG_LEVEL_CONSOLE_ERROR_Z "error" +#define CFGOPTVAL_LOG_LEVEL_CONSOLE_INFO_Z "info" +#define CFGOPTVAL_LOG_LEVEL_CONSOLE_OFF_Z "off" +#define CFGOPTVAL_LOG_LEVEL_CONSOLE_TRACE_Z "trace" +#define CFGOPTVAL_LOG_LEVEL_CONSOLE_WARN_Z "warn" + +#define CFGOPTVAL_LOG_LEVEL_FILE_DEBUG_Z "debug" +#define CFGOPTVAL_LOG_LEVEL_FILE_DETAIL_Z "detail" +#define CFGOPTVAL_LOG_LEVEL_FILE_ERROR_Z "error" +#define CFGOPTVAL_LOG_LEVEL_FILE_INFO_Z "info" +#define CFGOPTVAL_LOG_LEVEL_FILE_OFF_Z "off" +#define CFGOPTVAL_LOG_LEVEL_FILE_TRACE_Z "trace" +#define CFGOPTVAL_LOG_LEVEL_FILE_WARN_Z "warn" + +#define CFGOPTVAL_LOG_LEVEL_STDERR_DEBUG_Z "debug" +#define CFGOPTVAL_LOG_LEVEL_STDERR_DETAIL_Z "detail" +#define CFGOPTVAL_LOG_LEVEL_STDERR_ERROR_Z "error" +#define CFGOPTVAL_LOG_LEVEL_STDERR_INFO_Z "info" +#define CFGOPTVAL_LOG_LEVEL_STDERR_OFF_Z "off" +#define CFGOPTVAL_LOG_LEVEL_STDERR_TRACE_Z "trace" +#define CFGOPTVAL_LOG_LEVEL_STDERR_WARN_Z "warn" + +#define CFGOPTVAL_OUTPUT_JSON_Z "json" +#define CFGOPTVAL_OUTPUT_TEXT_Z "text" + +#define CFGOPTVAL_REMOTE_TYPE_PG_Z "pg" +#define CFGOPTVAL_REMOTE_TYPE_REPO_Z "repo" + +#define CFGOPTVAL_REPO_AZURE_KEY_TYPE_SAS_Z "sas" +#define CFGOPTVAL_REPO_AZURE_KEY_TYPE_SHARED_Z "shared" + +#define CFGOPTVAL_REPO_CIPHER_TYPE_AES_256_CBC_Z "aes-256-cbc" +#define CFGOPTVAL_REPO_CIPHER_TYPE_NONE_Z "none" + +#define CFGOPTVAL_REPO_GCS_KEY_TYPE_SERVICE_Z "service" +#define CFGOPTVAL_REPO_GCS_KEY_TYPE_TOKEN_Z "token" + +#define CFGOPTVAL_REPO_RETENTION_ARCHIVE_TYPE_DIFF_Z "diff" +#define CFGOPTVAL_REPO_RETENTION_ARCHIVE_TYPE_FULL_Z "full" +#define CFGOPTVAL_REPO_RETENTION_ARCHIVE_TYPE_INCR_Z "incr" + +#define CFGOPTVAL_REPO_RETENTION_FULL_TYPE_COUNT_Z "count" +#define CFGOPTVAL_REPO_RETENTION_FULL_TYPE_TIME_Z "time" + +#define CFGOPTVAL_REPO_S3_KEY_TYPE_AUTO_Z "auto" +#define CFGOPTVAL_REPO_S3_KEY_TYPE_SHARED_Z "shared" + +#define CFGOPTVAL_REPO_S3_URI_STYLE_HOST_Z "host" +#define CFGOPTVAL_REPO_S3_URI_STYLE_PATH_Z "path" + +#define CFGOPTVAL_REPO_TYPE_AZURE_Z "azure" +#define CFGOPTVAL_REPO_TYPE_CIFS_Z "cifs" +#define CFGOPTVAL_REPO_TYPE_GCS_Z "gcs" +#define CFGOPTVAL_REPO_TYPE_POSIX_Z "posix" +#define CFGOPTVAL_REPO_TYPE_S3_Z "s3" + +#define CFGOPTVAL_SORT_ASC_Z "asc" +#define CFGOPTVAL_SORT_DESC_Z "desc" +#define CFGOPTVAL_SORT_NONE_Z "none" + +#define CFGOPTVAL_TARGET_ACTION_PAUSE_Z "pause" +#define CFGOPTVAL_TARGET_ACTION_PROMOTE_Z "promote" +#define CFGOPTVAL_TARGET_ACTION_SHUTDOWN_Z "shutdown" + +#define CFGOPTVAL_TYPE_DEFAULT_Z "default" +#define CFGOPTVAL_TYPE_DIFF_Z "diff" +#define CFGOPTVAL_TYPE_FULL_Z "full" +#define CFGOPTVAL_TYPE_IMMEDIATE_Z "immediate" +#define CFGOPTVAL_TYPE_INCR_Z "incr" +#define CFGOPTVAL_TYPE_NAME_Z "name" +#define CFGOPTVAL_TYPE_NONE_Z "none" +#define CFGOPTVAL_TYPE_PRESERVE_Z "preserve" +#define CFGOPTVAL_TYPE_STANDBY_Z "standby" +#define CFGOPTVAL_TYPE_TIME_Z "time" +#define CFGOPTVAL_TYPE_XID_Z "xid" + /*********************************************************************************************************************************** Command enum ***********************************************************************************************************************************/ diff --git a/src/config/config.h b/src/config/config.h index db9dbb106..f9201d35f 100644 --- a/src/config/config.h +++ b/src/config/config.h @@ -43,12 +43,37 @@ typedef enum #define CFG_COMMAND_ROLE_TOTAL 4 /*********************************************************************************************************************************** -Constants +Constants for configuration option values -Constants for configuration options. +??? These should be generated automatically but for now just put them here so they are easy to find when it is time to replace them +with the auto-generated values. Note that the _Z variants of these constants are auto-generated. ***********************************************************************************************************************************/ -#define CFGOPTVAL_TMP_REPO_RETENTION_FULL_TYPE_COUNT "count" -#define CFGOPTVAL_TMP_REPO_RETENTION_FULL_TYPE_TIME "time" +#define CFGOPTVAL_ARCHIVE_MODE_OFF STRID5("off", 0x18cf0) +#define CFGOPTVAL_ARCHIVE_MODE_PRESERVE STRID5("preserve", 0x2da45996500) + +#define CFGOPTVAL_OUTPUT_TEXT STRID5("text", 0xa60b40) +#define CFGOPTVAL_OUTPUT_JSON STRID5("json", 0x73e6a0) + +#define CFGOPTVAL_REPO_RETENTION_ARCHIVE_TYPE_DIFF STRID5("diff", 0x319240) +#define CFGOPTVAL_REPO_RETENTION_ARCHIVE_TYPE_FULL STRID5("full", 0x632a60) +#define CFGOPTVAL_REPO_RETENTION_ARCHIVE_TYPE_INCR STRID5("incr", 0x90dc90) + +#define CFGOPTVAL_REPO_RETENTION_FULL_TYPE_COUNT STRID5("count", 0x14755e30) +#define CFGOPTVAL_REPO_RETENTION_FULL_TYPE_TIME STRID5("time", 0x2b5340) + +#define CFGOPTVAL_TARGET_ACTION_PAUSE STRID5("pause", 0x59d4300) +#define CFGOPTVAL_TARGET_ACTION_SHUTDOWN STRID5("shutdown", 0x75de4a55130) + +#define CFGOPTVAL_SORT_ASC STRID5("asc", 0xe610) +#define CFGOPTVAL_SORT_DESC STRID5("desc", 0x1cca40) +#define CFGOPTVAL_SORT_NONE STRID5("none", 0x2b9ee0) + +#define CFGOPTVAL_TYPE_DEFAULT STRID5("default", 0x5195098a40) +#define CFGOPTVAL_TYPE_IMMEDIATE STRID5("immediate", 0x5a05242b5a90) +#define CFGOPTVAL_TYPE_NONE STRID5("none", 0x2b9ee0) +#define CFGOPTVAL_TYPE_PRESERVE STRID5("preserve", 0x2da45996500) +#define CFGOPTVAL_TYPE_STANDBY STRID5("standby", 0x6444706930) +#define CFGOPTVAL_TYPE_TIME STRID5("time", 0x2b5340) /*********************************************************************************************************************************** Command Functions diff --git a/src/config/load.c b/src/config/load.c index 5271a5af9..c656b8cbd 100644 --- a/src/config/load.c +++ b/src/config/load.c @@ -215,9 +215,8 @@ cfgLoadUpdateOption(void) { case backupTypeFull: { - if (strEqZ( - cfgOptionIdxStr(cfgOptRepoRetentionFullType, optionIdx), - CFGOPTVAL_TMP_REPO_RETENTION_FULL_TYPE_COUNT) && + if (cfgOptionIdxStrId(cfgOptRepoRetentionFullType, optionIdx) == + CFGOPTVAL_REPO_RETENTION_FULL_TYPE_COUNT && cfgOptionIdxTest(cfgOptRepoRetentionFull, optionIdx)) { cfgOptionIdxSet(cfgOptRepoRetentionArchive, optionIdx, cfgSourceDefault, @@ -261,11 +260,10 @@ cfgLoadUpdateOption(void) if (archiveRetentionType == backupTypeDiff && !cfgOptionIdxTest(cfgOptRepoRetentionDiff, optionIdx)) { LOG_WARN_FMT( - "option '%s' is not set for '%s=%s'\n" + "option '%s' is not set for '%s=" CFGOPTVAL_TYPE_DIFF_Z "'\n" "HINT: to retain differential backups indefinitely (without warning), set option '%s' to the maximum.", cfgOptionIdxName(cfgOptRepoRetentionDiff, optionIdx), cfgOptionIdxName(cfgOptRepoRetentionArchiveType, optionIdx), - strZ(strIdToStr(backupTypeDiff)), cfgOptionIdxName(cfgOptRepoRetentionDiff, optionIdx)); } } diff --git a/test/src/module/command/restoreTest.c b/test/src/module/command/restoreTest.c index 5e0fc94e6..185986309 100644 --- a/test/src/module/command/restoreTest.c +++ b/test/src/module/command/restoreTest.c @@ -2239,7 +2239,7 @@ testRun(void) strLstAddZ(argList, "--" CFGOPT_STANZA "=test1"); hrnCfgArgRaw(argList, cfgOptRepoPath, repoPath); hrnCfgArgRaw(argList, cfgOptPgPath, pgPath); - strLstAddZ(argList, "--" CFGOPT_TYPE "=" RECOVERY_TYPE_PRESERVE); + hrnCfgArgRawStrId(argList, cfgOptType, CFGOPTVAL_TYPE_PRESERVE); strLstAddZ(argList, "--" CFGOPT_SET "=20161219-212741F"); strLstAddZ(argList, "--" CFGOPT_FORCE); harnessCfgLoad(cfgCmdRestore, argList);