@@ -54,7 +54,7 @@ func Travel(i Itinerary) (creds.Creds, error) {
54
54
if err := v .loadAccount (i .Args , i .Prompt ); err != nil {
55
55
return c , err
56
56
}
57
- if err := v .loadRole (i .RoleName , i .Prompt ); err != nil {
57
+ if err := v .loadRole (i .RoleName , i .Args , i . Prompt ); err != nil {
58
58
return c , err
59
59
}
60
60
if err := v .loadHops (); err != nil {
@@ -77,8 +77,14 @@ func (v *voyage) loadAccount(args []string, pf prompt.Func) error {
77
77
return err
78
78
}
79
79
80
- func (v * voyage ) loadRole (roleName string , pf prompt.Func ) error {
80
+ func (v * voyage ) loadRole (roleName string , args [] string , pf prompt.Func ) error {
81
81
var err error
82
+ if roleName == "" && len (args ) == 1 {
83
+ accountMatch := cartogram .AccountRegex .FindStringSubmatch (args [0 ])
84
+ if len (accountMatch ) > 2 {
85
+ roleName = accountMatch [2 ]
86
+ }
87
+ }
82
88
v .role , err = v .account .PickRoleWithPrompt (roleName , pf )
83
89
return err
84
90
}
@@ -163,12 +169,12 @@ func parseHops(stack *[]hop, cp cartogram.Pack, a cartogram.Account, r string) e
163
169
},
164
170
)
165
171
accountMatch := cartogram .AccountRegex .FindStringSubmatch (a .Source )
166
- if len (accountMatch ) != 4 {
172
+ if len (accountMatch ) != 3 {
167
173
* stack = append (* stack , hop {Profile : a .Source })
168
174
return nil
169
175
}
170
176
sAccountID := accountMatch [1 ]
171
- sRole := accountMatch [3 ]
177
+ sRole := accountMatch [2 ]
172
178
found , sAccount := cp .Lookup (sAccountID )
173
179
if ! found {
174
180
return fmt .Errorf ("Failed to resolve hop for %s" , sAccountID )
0 commit comments