command

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: MPL-2.0 Imports: 17 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package command holds the root command and what every subcommand shares (Deps). Subcommands live in command/<resource> and import this package; main.go is the only place that attaches them to the root.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApiTokenFromEnv

func ApiTokenFromEnv(getenv func(string) string) string

ApiTokenFromEnv is OPENVICLOUD_TOKEN without the spaces or newline a copy and paste brings along.

func EndpointsFromEnv

func EndpointsFromEnv(getenv func(string) string) session.Endpoints

func ExitCodeOf

func ExitCodeOf(code int) int

ExitCodeOf is the exit code to pass on for an ssh that ended with code: -1 (killed by a signal, no exit status) becomes 255, the code ssh uses for its own errors.

func NewIdempotencyKey

func NewIdempotencyKey() string

NewIdempotencyKey is the key of one create: sent with every attempt of that create, never with another (titan-ops architecture/http-contract.md#idempotency-key).

func NewRoot

func NewRoot(deps *Deps) *cobra.Command

func NewVersion

func NewVersion(deps *Deps) *cobra.Command

NewVersion prints the build and the endpoints it targets: the two things support asks first.

func OpenBrowser

func OpenBrowser(url string) error

OpenBrowser opens url in the default browser of the machine.

func RunSSH

func RunSSH(ctx context.Context, args []string) error

RunSSH runs the system ssh with the terminal of this process. Not tied to ctx: Ctrl-C reaches ssh from the terminal, and killing it instead would leave the terminal without echo at a passphrase prompt.

Types

type Deps

type Deps struct {
	Endpoints   session.Endpoints
	Sessions    *session.Manager
	Printer     *output.Printer
	HTTP        *http.Client
	Version     string
	OpenBrowser func(url string) error
	// For `vm ssh` and its tunnel: the tunnel reads ssh's bytes from Stdin; `vm ssh` starts the system ssh and
	// names this binary as its ProxyCommand.
	Stdin      io.Reader
	Executable func() (string, error)
	RunSSH     func(ctx context.Context, args []string) error
	// For --wait and for retrying a create.
	Clock wait.Clock
	// From OPENVICLOUD_TOKEN: when set, every request carries it instead of the login session, for CI and scripts
	// (titan-ops features/cli/design.md#api-token).
	ApiToken string
}

func (*Deps) AccessToken

func (d *Deps) AccessToken(ctx context.Context) (string, error)

AccessToken is the API token when one is set, else the logged-in customer's token for this endpoint, or the error that says how to log in.

func (*Deps) Client

func (d *Deps) Client(ctx context.Context) (*api.ClientWithResponses, error)

Client is an API client for a customer who is logged in to this endpoint and has accepted the current terms. Every command that needs a login starts here.

func (*Deps) Confirm

func (d *Deps) Confirm(question string) bool

Confirm asks the person at the terminal a yes/no question; only "y" or "yes" is yes. No answer (end of input) is no.

func (*Deps) TermsReminder

func (d *Deps) TermsReminder(ctx context.Context)

TermsReminder tells a customer who just logged in that the terms still need accepting. It never fails the login.

type ExitCode

type ExitCode struct {
	Code int
}

ExitCode is the error of a command whose exit code is another program's (ssh): main exits with it and prints nothing, the program already said why.

func (*ExitCode) Error

func (e *ExitCode) Error() string

Directories

Path Synopsis
Package auth is `openvicloud auth login|logout|status`.
Package auth is `openvicloud auth login|logout|status`.
Package catalog is what a customer chooses from when creating a VM: `cluster list`, `template list`, `size list`.
Package catalog is what a customer chooses from when creating a VM: `cluster list`, `template list`, `size list`.
Package sshkey is `openvicloud ssh-key`: the public keys of the tenant, picked when a VM is created (titan-ops features/vm/design.md#ssh-key).
Package sshkey is `openvicloud ssh-key`: the public keys of the tenant, picked when a VM is created (titan-ops features/vm/design.md#ssh-key).
Package tenant is `openvicloud tenant get`.
Package tenant is `openvicloud tenant get`.
Package vm is `openvicloud vm`: the VM lifecycle (lifecycle.go), and `vm ssh` with the tunnel it runs as ssh's ProxyCommand.
Package vm is `openvicloud vm`: the VM lifecycle (lifecycle.go), and `vm ssh` with the tunnel it runs as ssh's ProxyCommand.

Jump to

Keyboard shortcuts

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