Add global config for passing '--option' flags
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
IamTheFij 2022-11-03 15:34:17 -07:00
parent 8b5d15d4b2
commit c0e1795a80
2 changed files with 19 additions and 10 deletions

View File

@ -193,6 +193,7 @@ type ResticGlobalOpts struct {
TLSClientCertFile string `hcl:"TlsClientCertFile,optional"` TLSClientCertFile string `hcl:"TlsClientCertFile,optional"`
LimitDownload int `hcl:"LimitDownload,optional"` LimitDownload int `hcl:"LimitDownload,optional"`
LimitUpload int `hcl:"LimitUpload,optional"` LimitUpload int `hcl:"LimitUpload,optional"`
Options map[string]string `hcl:"Options,optional"`
VerboseLevel int `hcl:"VerboseLevel,optional"` VerboseLevel int `hcl:"VerboseLevel,optional"`
CleanupCache bool `hcl:"CleanupCache,optional"` CleanupCache bool `hcl:"CleanupCache,optional"`
NoCache bool `hcl:"NoCache,optional"` NoCache bool `hcl:"NoCache,optional"`
@ -211,6 +212,10 @@ func (glo ResticGlobalOpts) ToArgs() (args []string) {
args = maybeAddArgBool(args, "--no-cache", glo.NoCache) args = maybeAddArgBool(args, "--no-cache", glo.NoCache)
args = maybeAddArgBool(args, "--no-lock", glo.NoLock) args = maybeAddArgBool(args, "--no-lock", glo.NoLock)
for key, value := range glo.Options {
args = append(args, fmt.Sprintf("--option %s='%s'", key, value))
}
return args return args
} }

View File

@ -34,6 +34,9 @@ func TestGlobalOptions(t *testing.T) {
CleanupCache: true, CleanupCache: true,
NoCache: true, NoCache: true,
NoLock: true, NoLock: true,
Options: map[string]string{
"key": "a long value",
},
}.ToArgs() }.ToArgs()
expected := []string{ expected := []string{
@ -47,6 +50,7 @@ func TestGlobalOptions(t *testing.T) {
"--cleanup-cache", "--cleanup-cache",
"--no-cache", "--no-cache",
"--no-lock", "--no-lock",
"--option key='a long value'",
} }
AssertEqual(t, "args didn't match", expected, args) AssertEqual(t, "args didn't match", expected, args)