Help us shape the future of Go! Take the 2026 Go Developer Survey

laptop

package
v8.149.9 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package laptop is the wiring of the agent-facing engines on a laptop: the tokens from the keychain, a management cluster from a kubeconfig and tsh. The engines take the clients it builds; a server builds them from the tokens it holds for a person and never calls this package.

Index

Constants

View Source
const LoginTimeout = time.Minute

LoginTimeout bounds every tsh call: a profile checked valid does not prompt, so a call that does not return is a hung proxy.

Variables

View Source
var ErrNoTsh = errors.New("tsh is not installed")

ErrNoTsh is what Teleport answers when tsh is not installed: the kube context stays missing, nothing logs in.

Functions

func MissingContextError

func MissingContextError(installation, kubeContext string, contexts []string) error

MissingContextError is the usage error for a kube context the kubeconfig does not have. An installation reached through another context than the one tsh kube login writes (kubectl gs login's gs-<installation>, a lab's own) is named with --context; the kubeconfig's contexts that mention the installation are listed as the candidates.

func OpenCluster

func OpenCluster(ctx context.Context, c ClusterConfig) (dynamic.Interface, error)

OpenCluster opens the kube context of c with the requests going through c.Wrap. It reads the kubeconfig only, the cluster is not contacted.

When the kubeconfig lacks the Teleport context (rolloutwait.ContextPrefix + installation) and tsh is logged in, tsh kube login writes the context into a private temporary kubeconfig, which is read and removed again: neither the default kubeconfig nor --kubeconfig is written. A tsh that is not logged in is exit 8. Any other context that does not exist, or one tsh is not installed to write, is a usage error naming the contexts that mention the installation, --context and tsh kube login.

func ReleasePromoteSources

func ReleasePromoteSources(ctx context.Context, endpoints agentcli.Endpoints, transport http.RoundTripper, warn func(string)) (*releasepromote.Sources, error)

ReleasePromoteSources are the sources of a promotion on a laptop: the GitHub token of authstore.ResolveGitHub (the App login, or a token in the environment that overrides it; its warning goes to warn), renewed only when it is the keychain's. The requests go through transport.

func ReleaseWaitSources

func ReleaseWaitSources(ctx context.Context, endpoints agentcli.Endpoints, transport http.RoundTripper, warn func(string)) (*releasewait.Sources, error)

ReleaseWaitSources are the sources of a release wait on a laptop: the GitHub token through the gate, the CircleCI token through its gate when the tag turns out to carry a CircleCI configuration (its expiry notice to warn), and the private registry with the docker keychain, the credentials `docker login` stored. The GitHub and CircleCI requests go through transport.

Types

type ClusterConfig

type ClusterConfig struct {
	Installation string
	// Context is the kube context, [rolloutwait.ContextPrefix]+Installation by
	// default.
	Context string
	// Kubeconfig is the one file the context is read from; empty is the
	// default loading rules (KUBECONFIG, ~/.kube/config).
	Kubeconfig string
	// Wrap wraps the transport of every request.
	Wrap func(http.RoundTripper) http.RoundTripper
	// Teleport logs in when the kubeconfig lacks the Teleport context; nil
	// never logs in.
	Teleport Teleport
	// Progress is told about a login.
	Progress *agentcli.Progress
}

ClusterConfig names the management cluster OpenCluster opens.

type Teleport

type Teleport interface {
	// LoggedIn reports whether tsh holds a profile that is valid now, and
	// when not, why. ErrNoTsh when tsh is not installed.
	LoggedIn(ctx context.Context) (bool, string, error)
	// KubeLogin writes the installation's context, named kubeContext, into
	// the kubeconfig file, and nowhere else.
	KubeLogin(ctx context.Context, installation, kubeContext, kubeconfig string) error
}

Teleport logs in to an installation's management cluster, what OpenCluster falls back to for the Teleport context the kubeconfig lacks.

type Tsh

type Tsh struct {
	// Binary is the tsh to run; empty is tsh from PATH.
	Binary string
	// Now is the clock a profile's expiry is compared with; nil is
	// time.Now.
	Now func() time.Time
}

Tsh is Teleport through the tsh binary.

func (Tsh) KubeLogin

func (t Tsh) KubeLogin(ctx context.Context, installation, kubeContext, kubeconfig string) error

KubeLogin runs tsh kube login with KUBECONFIG set to kubeconfig for this one command, the context named kubeContext.

func (Tsh) LoggedIn

func (t Tsh) LoggedIn(ctx context.Context) (bool, string, error)

LoggedIn reads tsh status --format=json: no active profile, or one whose certificate has expired, is not logged in. tsh kube login would start an interactive login for either, which the check rules out.

Jump to

Keyboard shortcuts

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