Add global config for passing '--option' flags
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
8b5d15d4b2
commit
c0e1795a80
@ -193,6 +193,7 @@ type ResticGlobalOpts struct {
|
||||
TLSClientCertFile string `hcl:"TlsClientCertFile,optional"`
|
||||
LimitDownload int `hcl:"LimitDownload,optional"`
|
||||
LimitUpload int `hcl:"LimitUpload,optional"`
|
||||
Options map[string]string `hcl:"Options,optional"`
|
||||
VerboseLevel int `hcl:"VerboseLevel,optional"`
|
||||
CleanupCache bool `hcl:"CleanupCache,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-lock", glo.NoLock)
|
||||
|
||||
for key, value := range glo.Options {
|
||||
args = append(args, fmt.Sprintf("--option %s='%s'", key, value))
|
||||
}
|
||||
|
||||
return args
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,9 @@ func TestGlobalOptions(t *testing.T) {
|
||||
CleanupCache: true,
|
||||
NoCache: true,
|
||||
NoLock: true,
|
||||
Options: map[string]string{
|
||||
"key": "a long value",
|
||||
},
|
||||
}.ToArgs()
|
||||
|
||||
expected := []string{
|
||||
@ -47,6 +50,7 @@ func TestGlobalOptions(t *testing.T) {
|
||||
"--cleanup-cache",
|
||||
"--no-cache",
|
||||
"--no-lock",
|
||||
"--option key='a long value'",
|
||||
}
|
||||
|
||||
AssertEqual(t, "args didn't match", expected, args)
|
||||
|
Loading…
Reference in New Issue
Block a user