|
7 | 7 | "bufio"
|
8 | 8 | "fmt"
|
9 | 9 | "os"
|
10 |
| - "os/user" |
11 | 10 | "sort"
|
12 | 11 | "strings"
|
13 | 12 |
|
@@ -97,10 +96,12 @@ Examples:
|
97 | 96 | juju bootstrap
|
98 | 97 | juju bootstrap --clouds
|
99 | 98 | juju bootstrap --regions aws
|
100 |
| - juju bootstrap joe-us-east1 google |
101 |
| - juju bootstrap --config=~/config-rs.yaml joe-syd rackspace |
102 |
| - juju bootstrap --config agent-version=1.25.3 joe-us-east-1 aws |
103 |
| - juju bootstrap --config bootstrap-timeout=1200 joe-eastus azure |
| 99 | + juju bootstrap aws |
| 100 | + juju bootstrap aws/us-east-1 |
| 101 | + juju bootstrap google joe-us-east1 |
| 102 | + juju bootstrap --config=~/config-rs.yaml rackspace joe-syd |
| 103 | + juju bootstrap --config agent-version=1.25.3 aws joe-us-east-1 |
| 104 | + juju bootstrap --config bootstrap-timeout=1200 azure joe-eastus |
104 | 105 |
|
105 | 106 | See also:
|
106 | 107 | add-credentials
|
@@ -232,17 +233,16 @@ func (c *bootstrapCommand) Init(args []string) (err error) {
|
232 | 233 | // no args or flags, go interactive.
|
233 | 234 | c.interactive = true
|
234 | 235 | return nil
|
235 |
| - case 1: |
236 |
| - // The user must specify both positional arguments: the controller name, |
237 |
| - // and the cloud name (optionally with region specified). |
238 |
| - return errors.New("controller name and cloud name are required") |
239 | 236 | }
|
240 |
| - c.controllerName = args[0] |
241 |
| - c.Cloud = args[1] |
| 237 | + c.Cloud = args[0] |
242 | 238 | if i := strings.IndexRune(c.Cloud, '/'); i > 0 {
|
243 | 239 | c.Cloud, c.Region = c.Cloud[:i], c.Cloud[i+1:]
|
244 | 240 | }
|
245 |
| - return cmd.CheckEmpty(args[2:]) |
| 241 | + if len(args) > 1 { |
| 242 | + c.controllerName = args[1] |
| 243 | + return cmd.CheckEmpty(args[2:]) |
| 244 | + } |
| 245 | + return nil |
246 | 246 | }
|
247 | 247 |
|
248 | 248 | // BootstrapInterface provides bootstrap functionality that Run calls to support cleaner testing.
|
@@ -470,6 +470,9 @@ func (c *bootstrapCommand) Run(ctx *cmd.Context) (resultErr error) {
|
470 | 470 | )
|
471 | 471 | return cmd.ErrSilent
|
472 | 472 | }
|
| 473 | + if c.controllerName == "" { |
| 474 | + c.controllerName = defaultControllerName(c.Cloud, region.Name) |
| 475 | + } |
473 | 476 |
|
474 | 477 | controllerModelUUID, err := utils.NewUUID()
|
475 | 478 | if err != nil {
|
@@ -859,11 +862,7 @@ func (c *bootstrapCommand) runInteractive(ctx *cmd.Context) error {
|
859 | 862 | }
|
860 | 863 | }
|
861 | 864 |
|
862 |
| - var username string |
863 |
| - if u, err := user.Current(); err == nil { |
864 |
| - username = u.Username |
865 |
| - } |
866 |
| - defName := defaultControllerName(username, c.Cloud, c.Region, cloud) |
| 865 | + defName := defaultControllerName(c.Cloud, c.Region) |
867 | 866 |
|
868 | 867 | c.controllerName, err = queryName(defName, scanner, ctx.Stdout)
|
869 | 868 | if err != nil {
|
|
0 commit comments