From d2be5e82bd7de4372b52399f8f9653ab72e05f78 Mon Sep 17 00:00:00 2001 From: Marius Date: Mon, 16 Sep 2019 14:12:00 +0200 Subject: [PATCH] cli: Remove unneeded flag validation check Closes https://github.com/tus/tusd/issues/229 --- README.md | 2 +- cmd/tusd/cli/composer.go | 6 ++++++ cmd/tusd/cli/flags.go | 14 +------------- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 495db1e..3edbbc5 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ snippet demonstrates how to start a tusd process which accepts tus uploads at `http://localhost:1080/files/` (notice the trailing slash) and stores them locally in the `./data` directory: ``` -$ tusd -dir=./data +$ tusd -upload-dir./data [tusd] Using './data' as directory storage. [tusd] Using 0.00MB as maximum size. [tusd] Using 0.0.0.0:1080 as address to listen. diff --git a/cmd/tusd/cli/composer.go b/cmd/tusd/cli/composer.go index 95d8a4b..606e2f2 100644 --- a/cmd/tusd/cli/composer.go +++ b/cmd/tusd/cli/composer.go @@ -3,6 +3,7 @@ package cli import ( "os" "path/filepath" + "strings" "github.com/tus/tusd/pkg/filelocker" "github.com/tus/tusd/pkg/filestore" @@ -42,6 +43,11 @@ func CreateComposer() { locker := memorylocker.New() locker.UseIn(Composer) } else if Flags.GCSBucket != "" { + if Flags.GCSObjectPrefix != "" && strings.Contains(Flags.GCSObjectPrefix, "_") { + stderr.Fatalf("gcs-object-prefix value (%s) can't contain underscore. "+ + "Please remove underscore from the value", Flags.GCSObjectPrefix) + } + // Derivce credentials from service account file path passed in // GCS_SERVICE_ACCOUNT_FILE environment variable. gcsSAF := os.Getenv("GCS_SERVICE_ACCOUNT_FILE") diff --git a/cmd/tusd/cli/flags.go b/cmd/tusd/cli/flags.go index 6bf32b3..72a7b29 100644 --- a/cmd/tusd/cli/flags.go +++ b/cmd/tusd/cli/flags.go @@ -44,7 +44,7 @@ func ParseFlags() { flag.StringVar(&Flags.HttpPort, "port", "1080", "Port to bind HTTP server to") flag.StringVar(&Flags.HttpSock, "unix-sock", "", "If set, will listen to a UNIX socket at this location instead of a TCP socket") flag.Int64Var(&Flags.MaxSize, "max-size", 0, "Maximum size of a single upload in bytes") - flag.StringVar(&Flags.UploadDir, "dir", "./data", "Directory to store uploads in") + flag.StringVar(&Flags.UploadDir, "upload-dir", "./data", "Directory to store uploads in") flag.StringVar(&Flags.Basepath, "base-path", "/files/", "Basepath of the HTTP server") flag.Int64Var(&Flags.Timeout, "timeout", 30*1000, "Read timeout for connections in milliseconds. A zero value means that reads will not timeout") flag.StringVar(&Flags.S3Bucket, "s3-bucket", "", "Use AWS S3 with this bucket as storage backend (requires the AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_REGION environment variables to be set)") @@ -80,18 +80,6 @@ func ParseFlags() { stdout.Printf("Using '%s' as the endpoint for hooks", Flags.HttpHooksEndpoint) } - - if Flags.UploadDir == "" && Flags.S3Bucket == "" { - stderr.Fatalf("Either an upload directory (using -dir) or an AWS S3 Bucket " + - "(using -s3-bucket) must be specified to start tusd but " + - "neither flag was provided. Please consult `tusd -help` for " + - "more information on these options.") - } - - if Flags.GCSObjectPrefix != "" && strings.Contains(Flags.GCSObjectPrefix, "_") { - stderr.Fatalf("gcs-object-prefix value (%s) can't contain underscore. "+ - "Please remove underscore from the value", Flags.GCSObjectPrefix) - } } func SetEnabledHooks() {