Throw an error on an invalid bucket name

Signed-off-by: Nolan Brubaker <brubakern@vmware.com>
pull/1407/head
Nolan Brubaker 2019-04-25 16:14:10 -04:00
parent 011db15f1c
commit 9e19ab8d8b
2 changed files with 9 additions and 0 deletions

View File

@ -0,0 +1 @@
Disallow bucket names starting with '-'

View File

@ -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")
}