session

package
v1.11.1 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package session warns a user before they disconnect somebody from the serial console or the VNC of a virtual machine. Both streams are exclusive: connecting takes the stream over. The platform answers who holds it, and this is where that answer is turned into a decision.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Holder

func Holder(holder string) string

Holder shortens the identity of a session holder to what a human needs to find that person. A service account name is unreadable in full and its long form carries nothing extra.

Types

type Decision

type Decision int

Decision is what to do about a session somebody else is holding.

const (
	// Connect proceeds with the connection, disconnecting the holder.
	Connect Decision = iota
	// Abort leaves the holder alone and gives up on connecting.
	Abort
)

func AskBeforeConnecting

func AskBeforeConnecting(
	ctx context.Context,
	vms Prober,
	name string,
	kind subv1alpha2.SessionKind,
	force bool,
) Decision

AskBeforeConnecting is the check as a command needs it: it prepares the terminal to ask through and returns the decision. The client config is only needed to recognise the very user who asks, so a command that cannot get it still gets an answer.

func Check

func Check(
	ctx context.Context,
	vms Prober,
	name string,
	kind subv1alpha2.SessionKind,
	force bool,
	s Streams,
) Decision

Check asks who holds the stream and decides whether to connect.

It never stands between a user and a virtual machine: if the platform cannot answer — an older version that does not know the question, a denied or failed request — the connection proceeds as it always did. The same when the stream is free, or held by the very user who is asking.

type Prober

Prober is the part of the client this package needs: the very calls it would connect with, asked to report who holds the stream instead.

type Streams

type Streams struct {
	In       io.Reader
	Out      io.Writer
	IsATTY   bool
	SelfName func(ctx context.Context) (string, error)
}

Streams are the terminal the question is asked through, so tests can drive it.

func DefaultStreams

func DefaultStreams(restConfig *rest.Config) Streams

DefaultStreams asks through the real terminal.

Jump to

Keyboard shortcuts

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