env: add $RESTIC_CUSTOM_USER_AGENT to read custom user agent

This commit is contained in:
Srigovind Nayak 2024-05-22 01:57:56 +05:30
parent 7d54e2bdff
commit edd3b41014
No known key found for this signature in database
GPG Key ID: 3C4A72A34ABD4C43
2 changed files with 6 additions and 2 deletions

View File

@ -133,7 +133,7 @@ func init() {
f.IntVar(&globalOptions.Limits.DownloadKb, "limit-download", 0, "limits downloads to a maximum `rate` in KiB/s. (default: unlimited)")
f.UintVar(&globalOptions.PackSize, "pack-size", 0, "set target pack `size` in MiB, created pack files may be larger (default: $RESTIC_PACK_SIZE)")
f.StringSliceVarP(&globalOptions.Options, "option", "o", []string{}, "set extended option (`key=value`, can be specified multiple times)")
f.StringVar(&globalOptions.CustomUserAgent, "custom-user-agent", "", "set a custom user agent for outgoing http requests (default: 'Go-http-client/2.0')")
f.StringVar(&globalOptions.CustomUserAgent, "custom-user-agent", "", "set a custom user agent for outgoing http requests (default: $RESTIC_CUSTOM_USER_AGENT)")
// Use our "generate" command instead of the cobra provided "completion" command
cmdRoot.CompletionOptions.DisableDefaultCmd = true
@ -154,6 +154,10 @@ func init() {
// parse target pack size from env, on error the default value will be used
targetPackSize, _ := strconv.ParseUint(os.Getenv("RESTIC_PACK_SIZE"), 10, 32)
globalOptions.PackSize = uint(targetPackSize)
if os.Getenv("RESTIC_CUSTOM_USER_AGENT") == "" {
globalOptions.CustomUserAgent = os.Getenv("RESTIC_CUSTOM_USER_AGENT")
}
}
func stdinIsTerminal() bool {

View File

@ -51,7 +51,7 @@ Usage help is available:
--cache-dir directory set the cache directory. (default: use system default cache directory)
--cleanup-cache auto remove old cache directories
--compression mode compression mode (only available for repository format version 2), one of (auto|off|max) (default: $RESTIC_COMPRESSION) (default auto)
--custom-user-agent value set a custom user agent for outgoing http requests (default: 'Go-http-client/2.0')
--custom-user-agent value set a custom user agent for outgoing http requests (default: $RESTIC_CUSTOM_USER_AGENT)
-h, --help help for restic
--insecure-tls skip TLS certificate verification when connecting to the repository (insecure)
--json set output mode to JSON for commands that support it