mirror of
https://github.com/kopia/kopia.git
synced 2026-01-29 00:33:24 -05:00
* linter: upgraded to 1.33, disabled some linters * lint: fixed 'errorlint' errors This ensures that all error comparisons use errors.Is() or errors.As(). We will be wrapping more errors going forward so it's important that error checks are not strict everywhere. Verified that there are no exceptions for errorlint linter which guarantees that. * lint: fixed or suppressed wrapcheck errors * lint: nolintlint and misc cleanups Co-authored-by: Julio López <julio+gh@kasten.io>
50 lines
1.4 KiB
Go
50 lines
1.4 KiB
Go
package cli
|
|
|
|
import (
|
|
"context"
|
|
"io/ioutil"
|
|
|
|
"github.com/alecthomas/kingpin"
|
|
"github.com/pkg/errors"
|
|
|
|
"github.com/kopia/kopia/repo/blob"
|
|
"github.com/kopia/kopia/repo/blob/rclone"
|
|
)
|
|
|
|
func init() {
|
|
var (
|
|
opt rclone.Options
|
|
connectFlat bool
|
|
embedRCloneConfigFile string
|
|
)
|
|
|
|
RegisterStorageConnectFlags(
|
|
"rclone",
|
|
"an rclone-based provided",
|
|
func(cmd *kingpin.CmdClause) {
|
|
cmd.Flag("remote-path", "Rclone remote:path").Required().StringVar(&opt.RemotePath)
|
|
cmd.Flag("flat", "Use flat directory structure").BoolVar(&connectFlat)
|
|
cmd.Flag("rclone-exe", "Path to rclone binary").StringVar(&opt.RCloneExe)
|
|
cmd.Flag("rclone-args", "Pass additional parameters to rclone").StringsVar(&opt.RCloneArgs)
|
|
cmd.Flag("rclone-env", "Pass additional environment (key=value) to rclone").StringsVar(&opt.RCloneEnv)
|
|
cmd.Flag("embed-rclone-config", "Embed the provider RClone config").ExistingFileVar(&embedRCloneConfigFile)
|
|
},
|
|
func(ctx context.Context, isNew bool) (blob.Storage, error) {
|
|
if connectFlat {
|
|
opt.DirectoryShards = []int{}
|
|
}
|
|
|
|
if embedRCloneConfigFile != "" {
|
|
cfg, err := ioutil.ReadFile(embedRCloneConfigFile) //nolint:gosec
|
|
if err != nil {
|
|
return nil, errors.Wrap(err, "unable to read rclone config file")
|
|
}
|
|
|
|
opt.EmbeddedConfig = string(cfg)
|
|
}
|
|
|
|
return rclone.New(ctx, &opt)
|
|
},
|
|
)
|
|
}
|