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
- Variables
- func MissingContextError(installation, kubeContext string, contexts []string) error
- func OpenCluster(ctx context.Context, c ClusterConfig) (dynamic.Interface, error)
- func ReleasePromoteSources(ctx context.Context, endpoints agentcli.Endpoints, transport http.RoundTripper, ...) (*releasepromote.Sources, error)
- func ReleaseWaitSources(ctx context.Context, endpoints agentcli.Endpoints, transport http.RoundTripper, ...) (*releasewait.Sources, error)
- type ClusterConfig
- type Teleport
- type Tsh
Constants ¶
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 ¶
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 ¶
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 ¶
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.