terminal

package
v0.0.0-...-e779149 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 18, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Copyright 2022 The KubeSphere Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

View Source
var (
	NodeSessionCounter sync.Map
)

Functions

This section is empty.

Types

type Interface

type Interface interface {
	HandleSession(shell, namespace, podName, containerName string, conn *websocket.Conn)
	HandleShellAccessToNode(nodename string, conn *websocket.Conn)
}

func NewTerminaler

func NewTerminaler(client kubernetes.Interface, config *rest.Config, options *Options) Interface

type NodeTerminaler

type NodeTerminaler struct {
	Nodename      string
	Namespace     string
	PodName       string
	ContainerName string
	Shell         string
	Privileged    bool
	Config        *Options
	// contains filtered or unexported fields
}

func NewNodeTerminaler

func NewNodeTerminaler(nodename string, options *Options, client kubernetes.Interface) (*NodeTerminaler, error)

func (NodeTerminaler) CleanUpNSEnterPod

func (n NodeTerminaler) CleanUpNSEnterPod()

func (*NodeTerminaler) WatchPodStatusBeRunning

func (n *NodeTerminaler) WatchPodStatusBeRunning(pod *v1.Pod) error

type Options

type Options struct {
	Image   string `json:"image,omitempty" yaml:"image,omitempty"`
	Timeout int    `json:"timeout,omitempty" yaml:"timeout,omitempty"`
}

func NewTerminalOptions

func NewTerminalOptions() *Options

func (*Options) AddFlags

func (s *Options) AddFlags(fs *pflag.FlagSet, c *Options)

func (*Options) ApplyTo

func (s *Options) ApplyTo(options *Options)

func (*Options) Validate

func (s *Options) Validate() []error

type PtyHandler

type PtyHandler interface {
	io.Reader
	io.Writer
	remotecommand.TerminalSizeQueue
}

PtyHandler is what remotecommand expects from a pty

type TerminalMessage

type TerminalMessage struct {
	Op, Data   string
	Rows, Cols uint16
}

TerminalMessage is the messaging protocol between ShellController and TerminalSession.

OP DIRECTION FIELD(S) USED DESCRIPTION --------------------------------------------------------------------- stdin fe->be Data Keystrokes/paste buffer resize fe->be Rows, Cols New terminal size stdout be->fe Data Output from the process toast be->fe Data OOB message to be shown to the user

type TerminalSession

type TerminalSession struct {
	// contains filtered or unexported fields
}

TerminalSession implements PtyHandler (using a SockJS connection)

func (TerminalSession) Close

func (t TerminalSession) Close(status uint32, reason string)

Close shuts down the SockJS connection and sends the status code and reason to the client Can happen if the process exits or if there is an error starting up the process For now the status code is unused and reason is shown to the user (unless "")

func (TerminalSession) Next

Next handles pty->process resize events Called in a loop from remotecommand as long as the process is running

func (TerminalSession) Read

func (t TerminalSession) Read(p []byte) (int, error)

Read handles pty->process messages (stdin, resize) Called in a loop from remotecommand as long as the process is running

func (TerminalSession) Toast

func (t TerminalSession) Toast(p string) error

Toast can be used to send the user any OOB messages hterm puts these in the center of the terminal

func (TerminalSession) Write

func (t TerminalSession) Write(p []byte) (int, error)

Write handles process->pty stdout Called from remotecommand whenever there is any output

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL