@@ -15,12 +15,12 @@ type logger interface {
1515 Println (v ... interface {}) (int , error )
1616}
1717
18- func connectionReady (cs * api.Codespace ) bool {
19- return cs .Environment .Connection .SessionID != "" &&
20- cs .Environment .Connection .SessionToken != "" &&
21- cs .Environment .Connection .RelayEndpoint != "" &&
22- cs .Environment .Connection .RelaySAS != "" &&
23- cs .Environment .State == api .CodespaceEnvironmentStateAvailable
18+ func connectionReady (codespace * api.Codespace ) bool {
19+ return codespace .Environment .Connection .SessionID != "" &&
20+ codespace .Environment .Connection .SessionToken != "" &&
21+ codespace .Environment .Connection .RelayEndpoint != "" &&
22+ codespace .Environment .Connection .RelaySAS != "" &&
23+ codespace .Environment .State == api .CodespaceEnvironmentStateAvailable
2424}
2525
2626type apiClient interface {
@@ -30,17 +30,17 @@ type apiClient interface {
3030
3131// ConnectToLiveshare waits for a Codespace to become running,
3232// and connects to it using a Live Share session.
33- func ConnectToLiveshare (ctx context.Context , log logger , apiClient apiClient , cs * api.Codespace ) (* liveshare.Session , error ) {
33+ func ConnectToLiveshare (ctx context.Context , log logger , apiClient apiClient , codespace * api.Codespace ) (* liveshare.Session , error ) {
3434 var startedCodespace bool
35- if cs .Environment .State != api .CodespaceEnvironmentStateAvailable {
35+ if codespace .Environment .State != api .CodespaceEnvironmentStateAvailable {
3636 startedCodespace = true
3737 log .Print ("Starting your codespace..." )
38- if err := apiClient .StartCodespace (ctx , cs .Name ); err != nil {
38+ if err := apiClient .StartCodespace (ctx , codespace .Name ); err != nil {
3939 return nil , fmt .Errorf ("error starting codespace: %w" , err )
4040 }
4141 }
4242
43- for retries := 0 ; ! connectionReady (cs ); retries ++ {
43+ for retries := 0 ; ! connectionReady (codespace ); retries ++ {
4444 if retries > 1 {
4545 if retries % 2 == 0 {
4646 log .Print ("." )
@@ -54,7 +54,7 @@ func ConnectToLiveshare(ctx context.Context, log logger, apiClient apiClient, cs
5454 }
5555
5656 var err error
57- cs , err = apiClient .GetCodespace (ctx , cs .Name , true )
57+ codespace , err = apiClient .GetCodespace (ctx , codespace .Name , true )
5858 if err != nil {
5959 return nil , fmt .Errorf ("error getting codespace: %w" , err )
6060 }
@@ -67,10 +67,10 @@ func ConnectToLiveshare(ctx context.Context, log logger, apiClient apiClient, cs
6767 log .Println ("Connecting to your codespace..." )
6868
6969 return liveshare .Connect (ctx , liveshare.Options {
70- SessionID : cs .Environment .Connection .SessionID ,
71- SessionToken : cs .Environment .Connection .SessionToken ,
72- RelaySAS : cs .Environment .Connection .RelaySAS ,
73- RelayEndpoint : cs .Environment .Connection .RelayEndpoint ,
74- HostPublicKeys : cs .Environment .Connection .HostPublicKeys ,
70+ SessionID : codespace .Environment .Connection .SessionID ,
71+ SessionToken : codespace .Environment .Connection .SessionToken ,
72+ RelaySAS : codespace .Environment .Connection .RelaySAS ,
73+ RelayEndpoint : codespace .Environment .Connection .RelayEndpoint ,
74+ HostPublicKeys : codespace .Environment .Connection .HostPublicKeys ,
7575 })
7676}
0 commit comments