@@ -73,6 +73,8 @@ export interface WorkspaceContext {
73
73
checkPermissionsError ?: Error | unknown
74
74
// applications
75
75
applicationsHost ?: string
76
+ // SSH Config
77
+ sshPrefix ?: string
76
78
}
77
79
78
80
export type WorkspaceEvent =
@@ -163,6 +165,9 @@ export const workspaceMachine = createMachine(
163
165
getApplicationsHost : {
164
166
data : TypesGen . AppHostResponse
165
167
}
168
+ getSSHPrefix : {
169
+ data : TypesGen . SSHConfigResponse
170
+ }
166
171
} ,
167
172
} ,
168
173
initial : "idle" ,
@@ -457,6 +462,30 @@ export const workspaceMachine = createMachine(
457
462
} ,
458
463
} ,
459
464
} ,
465
+ sshConfig : {
466
+ initial : "gettingSshConfig" ,
467
+ states : {
468
+ gettingSshConfig : {
469
+ invoke : {
470
+ src : "getSSHPrefix" ,
471
+ onDone : {
472
+ target : "success" ,
473
+ actions : [ "assignSSHPrefix" ] ,
474
+ } ,
475
+ onError : {
476
+ target : "error" ,
477
+ actions : [ "displaySSHPrefixError" ] ,
478
+ } ,
479
+ } ,
480
+ } ,
481
+ error : {
482
+ type : "final" ,
483
+ } ,
484
+ success : {
485
+ type : "final" ,
486
+ } ,
487
+ } ,
488
+ } ,
460
489
schedule : {
461
490
invoke : {
462
491
id : "scheduleBannerMachine" ,
@@ -580,6 +609,17 @@ export const workspaceMachine = createMachine(
580
609
)
581
610
displayError ( message )
582
611
} ,
612
+ // SSH
613
+ assignSSHPrefix : assign ( {
614
+ sshPrefix : ( _ , { data } ) => data . hostname_prefix ,
615
+ } ) ,
616
+ displaySSHPrefixError : ( _ , { data } ) => {
617
+ const message = getErrorMessage (
618
+ data ,
619
+ "Error getting the deployment ssh configuration." ,
620
+ )
621
+ displayError ( message )
622
+ } ,
583
623
// Optimistically update. So when the user clicks on stop, we can show
584
624
// the "pending" state right away without having to wait 0.5s ~ 2s to
585
625
// display the visual feedback to the user.
@@ -737,6 +777,9 @@ export const workspaceMachine = createMachine(
737
777
getApplicationsHost : async ( ) => {
738
778
return API . getApplicationsHost ( )
739
779
} ,
780
+ getSSHPrefix : async ( ) => {
781
+ return API . getDeploymentSSHConfig ( )
782
+ } ,
740
783
} ,
741
784
} ,
742
785
)
0 commit comments