cli

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 42 Imported by: 0

Documentation

Overview

Package cli implements tenancyctl, the day-to-day client for the tenancy model: provisioning organization workspaces, creating tenants and projects, granting and revoking access, and asking the virtual workspace what the caller can reach.

It is deliberately a separate binary from the server: an administrator runs it with a kubeconfig, and an end user runs `whoami`/`kubeconfig` with nothing but their own credential and the virtual workspace's URL.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CachedToken

func CachedToken() string

CachedToken returns the token `login` cached in the default location, or "" when there is none, it expired, or more than one provider is cached.

func ClearSelection

func ClearSelection() error

ClearSelection forgets where the user was working, but keeps them logged in and keeps the server: they chose a project, not a cluster.

func Execute

func Execute() error

Execute runs the standalone tenancyctl binary.

func New

func New(use string) *cobra.Command

New builds the tenancy CLI command tree under the given name — "tenancyctl" for the standalone binary, "tenancy" when mounted as a subcommand of the repo-wide CLI. It registers no logging flags; the binary that owns the process does that once, at its own root.

func NewAdminCommand

func NewAdminCommand() *cobra.Command

NewAdminCommand groups everything that writes to kcp with a kubeconfig rather than answering from the caller's own credential: creating tenants and projects, bootstrapping an organization, seeding an environment. Whoever runs the platform uses these; a tenant does not.

func NewKubeconfigCommand

func NewKubeconfigCommand() *cobra.Command

NewKubeconfigCommand writes a kubeconfig for the caller's projects.

func NewLoginCommand

func NewLoginCommand() *cobra.Command

NewLoginCommand obtains a token from the identity provider and caches it.

func NewLogoutCommand

func NewLogoutCommand() *cobra.Command

NewLogoutCommand forgets the cached token.

func NewMembershipCommand

func NewMembershipCommand() *cobra.Command

NewMembershipCommand groups the grant lifecycle under one noun: `membership` lists, `membership add` grants, `membership remove` revokes.

Unlike the user-facing commands, these need a kubeconfig for kcp: a Membership lives in its tenant's workspace, which is the record store no member can enter, so managing access is an administrator's job by construction rather than by a check.

func NewProjectsCommand

func NewProjectsCommand() *cobra.Command

NewProjectsCommand lists the projects the caller can reach.

func NewSeedCommand

func NewSeedCommand() *cobra.Command

NewSeedCommand exposes seed for the tenancy binary, so a development environment (Tilt, a demo) can converge on baseline data with the component's own tooling and nothing else.

func NewTenantsCommand

func NewTenantsCommand() *cobra.Command

NewTenantsCommand lists the tenants the caller is a member of.

func NewUseCommand

func NewUseCommand() *cobra.Command

NewUseCommand selects the tenant and project later commands default to.

func NewWhoAmICommand

func NewWhoAmICommand() *cobra.Command

NewWhoAmICommand shows the tenants and projects the caller can reach.

func WriteSelection

func WriteSelection(s Selection) error

WriteSelection stores the selection, leaving the rest of the context — the server, the TLS settings — as it was.

Types

type Selection

type Selection struct {
	Tenant  string
	Project string
	// URL is the project's workspace, as the virtual workspace reported
	// it, so commands that only need somewhere to talk to do not have to
	// ask again.
	URL string
}

Selection is the tenant and project the user is currently working in: what `use` picks, and what every command that needs a workspace falls back to when no flag names one.

It is a view onto the shared CLI context in ~/.kube, which also holds the server `login` learned — one file, so a command never has to be told twice where anything is.

func CurrentSelection

func CurrentSelection() Selection

CurrentSelection reads the selection from the shared context.

func (Selection) Empty

func (s Selection) Empty() bool

Empty reports whether nothing has been selected yet.

func (Selection) String

func (s Selection) String() string

String renders the selection the way the CLI prints it.

Jump to

Keyboard shortcuts

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