Validate and error on invalid cloudUrl formats on pulumi login (#5550)
Fixes: #3382 ``` ▶ pulumi login --cloud-url az://myblob error: unknown backend cloudUrl format 'az' (supported Url formats are: azblob://, gs:// and s3://) ```
This commit is contained in:
parent
64577f5b10
commit
df9c9f195f
|
@ -37,6 +37,9 @@ CHANGELOG
|
|||
|
||||
- [cli] Ensure old secret provider variables are cleaned up when changing between secret providers
|
||||
[#5545](https://github.com/pulumi/pulumi/pull/5545)
|
||||
|
||||
- [cli] Validate cloudUrl formats before `pulumi login` and throw an error if incorrect format specified
|
||||
[#5550](https://github.com/pulumi/pulumi/pull/5545)
|
||||
|
||||
## 2.11.2 (2020-10-01)
|
||||
|
||||
|
|
|
@ -116,6 +116,11 @@ func newLoginCmd() *cobra.Command {
|
|||
if err != nil {
|
||||
return errors.Wrap(err, "could not determine current cloud")
|
||||
}
|
||||
} else {
|
||||
// Ensure we have the correct cloudurl type before logging in
|
||||
if err := validateCloudBackendType(cloudURL); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
var be backend.Backend
|
||||
|
@ -144,3 +149,18 @@ func newLoginCmd() *cobra.Command {
|
|||
|
||||
return cmd
|
||||
}
|
||||
|
||||
func validateCloudBackendType(typ string) error {
|
||||
kind := strings.SplitN(typ, ":", 2)[0]
|
||||
supportedKinds := []string{"azblob", "gs", "s3", "file", "https"}
|
||||
for _, supportedKind := range supportedKinds {
|
||||
if kind == supportedKind {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
return errors.Errorf(
|
||||
"unknown backend cloudUrl format '%s' (supported Url formats are: "+
|
||||
"azblob://, gs://, s3://, file:// and https://)",
|
||||
kind,
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue