mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-01-07 05:46:37 +00:00
Throw an error on an invalid bucket name
Signed-off-by: Nolan Brubaker <brubakern@vmware.com>
This commit is contained in:
@@ -21,6 +21,7 @@ import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
@@ -210,6 +211,13 @@ func (o *InstallOptions) Validate(c *cobra.Command, args []string, f client.Fact
|
||||
return errors.New("--bucket is required")
|
||||
}
|
||||
|
||||
// Our main 3 providers don't support bucket names starting with a dash, and a bucket name starting with one
|
||||
// can indicate that an environment variable was left blank.
|
||||
// This case will help catch that error
|
||||
if strings.HasPrefix(o.BucketName, "-") {
|
||||
return errors.Errorf("Bucket names cannot begin with a dash. Bucket name was: %s", o.BucketName)
|
||||
}
|
||||
|
||||
if o.ProviderName == "" {
|
||||
return errors.New("--provider is required")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user