55 "fmt"
66
77 "github.com/AndreZiviani/aws-fuzzy/internal/tracing"
8- "github.com/aws/aws-sdk-go-v2/aws"
98 "github.com/common-fate/granted/pkg/browsers"
109 "github.com/common-fate/granted/pkg/config"
1110 "github.com/common-fate/granted/pkg/debug"
@@ -31,34 +30,36 @@ func (p *Console) Execute(args []string) error {
3130 debug .CliVerbosity = debug .VerbosityDebug
3231 }
3332
34- creds , err := login .GetCredentials (ctx )
35- if err != nil {
36- return err
37- }
38-
39- p .OpenBrowser (ctx , creds )
33+ p .OpenBrowser (ctx )
4034
4135 return err
4236}
4337
44- func (p * Console ) OpenBrowser (ctx context.Context , credentials * aws. Credentials ) error {
38+ func (p * Console ) OpenBrowser (ctx context.Context ) error {
4539 span , ctx := opentracing .StartSpanFromContext (ctx , "ssorolecreds" )
4640 defer span .Finish ()
4741
48- login := Login {}
42+ login := Login {Profile : p . Profile }
4943 login .LoadProfiles ()
5044 profile , err := login .GetProfile (p .Profile )
5145 if err != nil {
5246 return err
5347 }
5448
49+ credentials , err := login .GetCredentials (ctx )
50+ if err != nil {
51+ return err
52+ }
53+
54+ session := browsers .SessionFromCredentials (* credentials )
55+
5556 region := p .Region
5657 if len (profile .AWSConfig .Region ) > 0 {
5758 region = profile .AWSConfig .Region
5859 }
5960
6061 browserOpts := browsers.BrowserOpts {Profile : profile .Name }
61- url , err := browsers .MakeUrl (browsers . SessionFromCredentials ( * credentials ) , browserOpts , "" , region )
62+ url , err := browsers .MakeUrl (session , browserOpts , "" , region )
6263 if err != nil {
6364 return err
6465 }
@@ -77,5 +78,5 @@ func (p *Console) OpenBrowser(ctx context.Context, credentials *aws.Credentials)
7778 return nil
7879 }
7980
80- return browsers .LaunchConsoleSession (browsers . SessionFromCredentials ( * credentials ) , browserOpts , "" , region )
81+ return browsers .LaunchConsoleSession (session , browserOpts , "" , region )
8182}
0 commit comments