Throw an error on an invalid bucket name
Signed-off-by: Nolan Brubaker <brubakern@vmware.com>pull/1407/head
parent
011db15f1c
commit
9e19ab8d8b
|
@ -0,0 +1 @@
|
|||
Disallow bucket names starting with '-'
|
|
@ -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")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue