mirror of
https://github.com/kopia/kopia.git
synced 2026-10-23 22:58:42 -04:00
moved CLI storage support to cli/
This commit is contained in:
1 parent
91066f2469
commit
6d2d663cac
6 files changed
+65
-79
No files matched your search
@@ -5,7 +5,6 @@ import (
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/kopia/kopia/cli"
|
||||
"github.com/kopia/kopia/repo/storage"
|
||||
"github.com/kopia/kopia/repo/storage/filesystem"
|
||||
"gopkg.in/alecthomas/kingpin.v2"
|
||||
@@ -44,7 +43,7 @@ func connect(ctx context.Context) (storage.Storage, error) {
|
||||
}
|
||||
|
||||
func init() {
|
||||
cli.RegisterStorageConnectFlags(
|
||||
RegisterStorageConnectFlags(
|
||||
"filesystem",
|
||||
"a filesystem",
|
||||
func(cmd *kingpin.CmdClause) {
|
||||
@@ -3,20 +3,15 @@ package cli
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/kopia/kopia/cli"
|
||||
"github.com/kopia/kopia/repo/storage"
|
||||
"github.com/kopia/kopia/repo/storage/gcs"
|
||||
"gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
var options gcs.Options
|
||||
|
||||
func connect(ctx context.Context) (storage.Storage, error) {
|
||||
return gcs.New(ctx, &options)
|
||||
}
|
||||
|
||||
func init() {
|
||||
cli.RegisterStorageConnectFlags(
|
||||
var options gcs.Options
|
||||
|
||||
RegisterStorageConnectFlags(
|
||||
"google",
|
||||
"a Google Cloud Storage bucket",
|
||||
func(cmd *kingpin.CmdClause) {
|
||||
@@ -28,5 +23,8 @@ func init() {
|
||||
cmd.Flag("max-upload-speed", "Limit the upload speed.").PlaceHolder("BYTES_PER_SEC").IntVar(&options.MaxUploadSpeedBytesPerSecond)
|
||||
|
||||
},
|
||||
connect)
|
||||
func(ctx context.Context) (storage.Storage, error) {
|
||||
return gcs.New(ctx, &options)
|
||||
},
|
||||
)
|
||||
}
|
||||
@@ -3,32 +3,29 @@ package cli
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/kopia/kopia/cli"
|
||||
"github.com/kopia/kopia/repo/storage"
|
||||
"github.com/kopia/kopia/repo/storage/s3"
|
||||
"gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
var options s3.Options
|
||||
|
||||
func connect(ctx context.Context) (storage.Storage, error) {
|
||||
return s3.New(ctx, &options)
|
||||
}
|
||||
|
||||
func init() {
|
||||
cli.RegisterStorageConnectFlags(
|
||||
var s3options s3.Options
|
||||
|
||||
RegisterStorageConnectFlags(
|
||||
"s3",
|
||||
"an S3 bucket",
|
||||
func(cmd *kingpin.CmdClause) {
|
||||
cmd.Flag("bucket", "Name of the S3 bucket").Required().StringVar(&options.BucketName)
|
||||
cmd.Flag("endpoint", "Endpoint to use").Default("s3.amazonaws.com").StringVar(&options.Endpoint)
|
||||
cmd.Flag("access-key", "Access key ID (overrides AWS_ACCESS_KEY_ID environment variable)").Required().Envar("AWS_ACCESS_KEY_ID").StringVar(&options.AccessKeyID)
|
||||
cmd.Flag("secret-access-key", "Secret access key (overrides AWS_SECRET_ACCESS_KEY environment variable)").Required().Envar("AWS_SECRET_ACCESS_KEY").StringVar(&options.SecretAccessKey)
|
||||
cmd.Flag("prefix", "Prefix to use for objects in the bucket").StringVar(&options.Prefix)
|
||||
cmd.Flag("disable-tls", "Disable TLS security (HTTPS)").BoolVar(&options.DoNotUseTLS)
|
||||
cmd.Flag("max-download-speed", "Limit the download speed.").PlaceHolder("BYTES_PER_SEC").IntVar(&options.MaxDownloadSpeedBytesPerSecond)
|
||||
cmd.Flag("max-upload-speed", "Limit the upload speed.").PlaceHolder("BYTES_PER_SEC").IntVar(&options.MaxUploadSpeedBytesPerSecond)
|
||||
|
||||
cmd.Flag("bucket", "Name of the S3 bucket").Required().StringVar(&s3options.BucketName)
|
||||
cmd.Flag("endpoint", "Endpoint to use").Default("s3.amazonaws.com").StringVar(&s3options.Endpoint)
|
||||
cmd.Flag("access-key", "Access key ID (overrides AWS_ACCESS_KEY_ID environment variable)").Required().Envar("AWS_ACCESS_KEY_ID").StringVar(&s3options.AccessKeyID)
|
||||
cmd.Flag("secret-access-key", "Secret access key (overrides AWS_SECRET_ACCESS_KEY environment variable)").Required().Envar("AWS_SECRET_ACCESS_KEY").StringVar(&s3options.SecretAccessKey)
|
||||
cmd.Flag("prefix", "Prefix to use for objects in the bucket").StringVar(&s3options.Prefix)
|
||||
cmd.Flag("disable-tls", "Disable TLS security (HTTPS)").BoolVar(&s3options.DoNotUseTLS)
|
||||
cmd.Flag("max-download-speed", "Limit the download speed.").PlaceHolder("BYTES_PER_SEC").IntVar(&s3options.MaxDownloadSpeedBytesPerSecond)
|
||||
cmd.Flag("max-upload-speed", "Limit the upload speed.").PlaceHolder("BYTES_PER_SEC").IntVar(&s3options.MaxUploadSpeedBytesPerSecond)
|
||||
},
|
||||
connect)
|
||||
func(ctx context.Context) (storage.Storage, error) {
|
||||
return s3.New(ctx, &s3options)
|
||||
},
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/kopia/kopia/repo/storage"
|
||||
"github.com/kopia/kopia/repo/storage/webdav"
|
||||
"gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
func init() {
|
||||
var (
|
||||
options webdav.Options
|
||||
connectFlat bool
|
||||
)
|
||||
|
||||
RegisterStorageConnectFlags(
|
||||
"webdav",
|
||||
"a WebDAV storage",
|
||||
func(cmd *kingpin.CmdClause) {
|
||||
cmd.Flag("url", "URL of WebDAV server").Required().StringVar(&options.URL)
|
||||
cmd.Flag("flat", "Use flat directory structure").BoolVar(&connectFlat)
|
||||
},
|
||||
func(ctx context.Context) (storage.Storage, error) {
|
||||
wo := options
|
||||
|
||||
if wo.Username != "" {
|
||||
pass, err := AskPass("Enter WebDAV password: ")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
wo.Password = pass
|
||||
}
|
||||
|
||||
if connectFlat {
|
||||
wo.DirectoryShards = []int{}
|
||||
}
|
||||
|
||||
return webdav.New(ctx, &wo)
|
||||
})
|
||||
}
|
||||
@@ -29,11 +29,6 @@ import (
|
||||
"gopkg.in/alecthomas/kingpin.v2"
|
||||
|
||||
logging "github.com/op/go-logging"
|
||||
|
||||
_ "github.com/kopia/kopia/repo/storage/filesystem/cli"
|
||||
_ "github.com/kopia/kopia/repo/storage/gcs/cli"
|
||||
_ "github.com/kopia/kopia/repo/storage/s3/cli"
|
||||
_ "github.com/kopia/kopia/repo/storage/webdav/cli"
|
||||
)
|
||||
|
||||
var fileLogFormat = logging.MustStringFormatter(
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/kopia/kopia/cli"
|
||||
"github.com/kopia/kopia/repo/storage"
|
||||
"github.com/kopia/kopia/repo/storage/webdav"
|
||||
"gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
var (
|
||||
options webdav.Options
|
||||
connectFlat bool
|
||||
)
|
||||
|
||||
func connect(ctx context.Context) (storage.Storage, error) {
|
||||
wo := options
|
||||
|
||||
if wo.Username != "" {
|
||||
pass, err := cli.AskPass("Enter WebDAV password: ")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
wo.Password = pass
|
||||
}
|
||||
|
||||
if connectFlat {
|
||||
wo.DirectoryShards = []int{}
|
||||
}
|
||||
|
||||
return webdav.New(ctx, &wo)
|
||||
}
|
||||
|
||||
func init() {
|
||||
cli.RegisterStorageConnectFlags(
|
||||
"webdav",
|
||||
"a WebDAV storage",
|
||||
func(cmd *kingpin.CmdClause) {
|
||||
cmd.Flag("url", "URL of WebDAV server").Required().StringVar(&options.URL)
|
||||
cmd.Flag("flat", "Use flat directory structure").BoolVar(&connectFlat)
|
||||
},
|
||||
connect)
|
||||
}
|
||||
Reference in new issue
Block a user