Add global config for passing '--option' flags
continuous-integration/drone/push Build is passing Details

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

@ -187,16 +187,17 @@ func (fo ForgetOpts) ToArgs() (args []string) {
}
type ResticGlobalOpts struct {
CaCertFile string `hcl:"CaCertFile,optional"`
CacheDir string `hcl:"CacheDir,optional"`
PasswordFile string `hcl:"PasswordFile,optional"`
TLSClientCertFile string `hcl:"TlsClientCertFile,optional"`
LimitDownload int `hcl:"LimitDownload,optional"`
LimitUpload int `hcl:"LimitUpload,optional"`
VerboseLevel int `hcl:"VerboseLevel,optional"`
CleanupCache bool `hcl:"CleanupCache,optional"`
NoCache bool `hcl:"NoCache,optional"`
NoLock bool `hcl:"NoLock,optional"`
CaCertFile string `hcl:"CaCertFile,optional"`
CacheDir string `hcl:"CacheDir,optional"`
PasswordFile string `hcl:"PasswordFile,optional"`
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"`
NoLock bool `hcl:"NoLock,optional"`
}
func (glo ResticGlobalOpts) ToArgs() (args []string) {
@ -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
}

View File

@ -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)