Documentation
¶
Overview ¶
Package clicontext holds what the CLI remembers between commands: the server it talks to, and where the user is working.
It lives beside the kubeconfig, in ~/.kube, because it is the same kind of thing — the local note about which cluster you mean — and because anyone debugging a CLI looks there first.
It belongs to the tenancy CLI because that is where it is written: `login` learns the server, `use` picks the project. Other components' commands are handed what they need from it by whichever binary composes them (contribctl), the way the marketplace's `enable` is handed a workspace resolver — so the components still never import each other, and a component's CLI on its own needs nothing but its flags.
Nothing here authorizes anything. It is a convenience that saves repeating flags — kcp decides what the caller may do.
Index ¶
Constants ¶
const EnvPath = "CONTRIBCTL_CONTEXT"
EnvPath overrides where the context is stored.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Context ¶
type Context struct {
// Server is the front-proxy's base URL, e.g.
// https://kcp.example.com:8443. Every virtual workspace hangs off it
// under /services/<name>, so one address is all a client needs.
Server string `json:"server,omitempty"`
// Tenant and Project are what `use` selected.
Tenant string `json:"tenant,omitempty"`
Project string `json:"project,omitempty"`
// WorkspaceURL is the selected project's own workspace, as the
// tenancy virtual workspace reported it.
WorkspaceURL string `json:"workspaceURL,omitempty"`
// Insecure records that the servers' certificates are not verified,
// so a development setup does not need the flag on every command.
Insecure bool `json:"insecureSkipTLSVerify,omitempty"`
// CertificateAuthority is the CA bundle that verifies them, when they
// are verified.
CertificateAuthority string `json:"certificateAuthority,omitempty"`
}
Context is the CLI's memory between invocations.
func Load ¶
func Load() Context
Load reads the stored context. A missing or unreadable file is an empty context, not an error: every caller has to cope with "nothing chosen yet" anyway, and a corrupt file should not make the CLI unusable.
func (Context) ServiceURL ¶
ServiceURL is where a virtual workspace answers on the stored server: the front-proxy routes /services/<name> to it.
Empty when no server is known, which is the caller's cue to ask for one — the CLI cannot guess an address.