@@ -38,7 +38,7 @@ type TUI struct {
3838 // Handle kubernetes session connections
3939 subscriptionHandler subscriptionHandler
4040 isListening bool
41- kubeComm * KubernetesHandlerComm
41+ runtimeCommunicator * RuntimeCommunicator
4242 exitedSession bool
4343}
4444
@@ -94,15 +94,15 @@ type subscriptionHandler struct {
9494}
9595
9696// newSubscription creates a new subscription handler with an async data channel
97- func newSubscription (gcvalues * command.GenericParams , kubeComm * KubernetesHandlerComm ) subscriptionHandler {
97+ func newSubscription (gcvalues * command.GenericParams , runtimeCommunicator * RuntimeCommunicator ) subscriptionHandler {
9898 dataChan := make (chan terminalStartMessage )
99- go launchSessionHandler (dataChan , gcvalues , kubeComm )
99+ go launchSessionHandler (dataChan , gcvalues , runtimeCommunicator )
100100 return subscriptionHandler {
101101 dataChan : dataChan ,
102102 }
103103}
104104
105- func launchSessionHandler (dataChan chan terminalStartMessage , gcvalues * command.GenericParams , kubeComm * KubernetesHandlerComm ) {
105+ func launchSessionHandler (dataChan chan terminalStartMessage , gcvalues * command.GenericParams , runtimeCommunicator * RuntimeCommunicator ) {
106106 // Create a subscription channel and define subscriptionChannels map for passing data
107107 subscriptionChannel := make (chan interface {})
108108 subscriptionChannels := map [string ]chan interface {}{
@@ -117,21 +117,34 @@ func launchSessionHandler(dataChan chan terminalStartMessage, gcvalues *command.
117117 subscriptionChannels ,
118118 )
119119
120- // Define command parameters for k8s runtime
120+ // Define command parameters for docker runtime
121121 // + Hard coded values at the moment for this PoC
122122 cparams := & CommandParams {
123- Runtime : "k8s" ,
124- TargetRef : "nginx" ,
125- Kubeconfig : crt .KubeconfigDefault ,
126- TargetNamespace : "default" ,
123+ Runtime : "docker" ,
124+ TargetRef : "docker-amor" ,
127125 DebugContainerImage : BusyboxImage ,
128126 DoFallbackToTargetUser : true ,
129127 DoRunAsTargetShell : true ,
130128 DoTerminal : true ,
131- KubeComm : kubeComm ,
129+ RuntimeCommunicator : runtimeCommunicator ,
132130 TUI : true ,
133131 }
134132
133+ // Connect to active session | Kubernetes session
134+ // cparams := &CommandParams{
135+ // Runtime: "docker",
136+ // TargetRef: "docker-amor",
137+ // // Kubeconfig: crt.KubeconfigDefault,
138+ // // TargetNamespace: "default",
139+ // DebugContainerImage: BusyboxImage,
140+ // DoFallbackToTargetUser: true,
141+ // DoRunAsTargetShell: true,
142+ // DoTerminal: true,
143+ // RuntimeCommunicator: runtimeCommunicator,
144+ // TUI: true,
145+ // ActionConnectSession: true,
146+ // }
147+
135148 // TODO - Pass runtime communicator
136149 go OnCommand (xc , gcvalues , cparams )
137150
@@ -160,7 +173,7 @@ func launchSessionHandler(dataChan chan terminalStartMessage, gcvalues *command.
160173 if infoValue , exists := channelResponse ["info" ]; exists {
161174 if infoValue == "terminal.start" {
162175 dataChan <- terminalStartMessage ("Session ready. Opening session below...\n Press esc to exit session.\n " )
163- kubeComm .InputChan <- InputKey {Special : Enter }
176+ runtimeCommunicator .InputChan <- InputKey {Special : Enter }
164177 }
165178 }
166179 }
@@ -198,7 +211,7 @@ func InitialTUI(standalone bool, gcvalues *command.GenericParams) *TUI {
198211// This handler should not live on CommandParams,
199212// but be passed in to OnCommand, then to the respective
200213// runtime handler.
201- type KubernetesHandlerComm struct {
214+ type RuntimeCommunicator struct {
202215 InputChan chan InputKey
203216}
204217
@@ -348,7 +361,7 @@ func (m TUI) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
348361 }
349362
350363 select {
351- case m .kubeComm .InputChan <- inputKey :
364+ case m .runtimeCommunicator .InputChan <- inputKey :
352365 // Key sent successfully
353366 default :
354367 // Channel is full or closed, handle accordingly
@@ -390,11 +403,11 @@ func (m TUI) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
390403 // this can be done by rendering state output,
391404 m .isListening = true
392405 log .Debug ("Start listening" )
393- kubeComm := & KubernetesHandlerComm {
406+ runtimeCommunicator := & RuntimeCommunicator {
394407 InputChan : make (chan InputKey , 100 ),
395408 }
396- m .kubeComm = kubeComm
397- m .subscriptionHandler = newSubscription (m .gcvalues , kubeComm )
409+ m .runtimeCommunicator = runtimeCommunicator
410+ m .subscriptionHandler = newSubscription (m .gcvalues , runtimeCommunicator )
398411 return m , listenToAsyncData (m .subscriptionHandler .dataChan )
399412
400413 }
0 commit comments