cmd

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ExitOK             = 0
	ExitGeneric        = 1
	ExitResourceFailed = 2
	ExitAuthRequired   = 3
	// ExitSessionExpired collapses to the same value as ExitAuthRequired: an
	// agent script only needs one branch ("any auth issue → re-login") and
	// the documented contract advertises 0/1/2/3.
	ExitSessionExpired = ExitAuthRequired
)

Exit codes — the public contract the CLI promises.

Variables

View Source
var APIBaseURL = "https://api.instanode.dev"

APIBaseURL is the instanode.dev API base URL. Resolved at init from (in priority order):

  1. INSTANT_API_URL env var
  2. ~/.instant-config api_base_url
  3. Default: https://api.instanode.dev
View Source
var HTTPClient = &http.Client{Timeout: httpProvisionTimeout}

HTTPClient is the shared HTTP client used by all subcommands. It is configured with the auth transport during init.

IMPORTANT: HTTPClient's Timeout is set to httpProvisionTimeout because provisioning + reconcile use this client. The few read-only `resources` and auth-poll paths are still safe because their requests complete in milliseconds; the longer ceiling is harmless. We keep one client (rather than two) to preserve the auth transport wiring through cobra OnInitialize.

Functions

func Execute

func Execute() error

Execute runs the root command.

This is intentionally a 1-line wrapper around ExecuteWithArgs so the production callsite (main.go) and tests share the same entry point. Tests use ExecuteWithArgs directly to assert behaviour without polluting os.Args.

func ExecuteWithArgs

func ExecuteWithArgs(args []string) error

ExecuteWithArgs runs the root command with an explicit args slice. The production callsite passes os.Args[1:]; tests pass a fixed slice.

func ExitCodeFor

func ExitCodeFor(err error) int

ExitCodeFor returns the exit code for an error: 0 for nil, the embedded code if it is an *ExitCodeError, else ExitGeneric (1). main.go uses this to translate any error from the cobra tree into os.Exit(n).

func SetBuildInfo

func SetBuildInfo(version, commit, buildTime string)

SetBuildInfo wires the ldflag-stamped Version/Commit/BuildTime from main into the cobra root so `instant --version` prints them. Called from main.go::main(). Kept here (rather than init()) so the seam between the main package and cmd/ stays explicit and so tests can override it.

B15-P0 (2): CLAUDE.md rule 14 requires every deploy to verify the live binary's commit matches `git rev-parse --short HEAD`. For the CLI, that gate is `instant --version | grep <sha>` — which can only be satisfied if the linker actually stamped these vars.

Types

type ExitCodeError

type ExitCodeError struct {
	Code int
	Err  error
}

ExitCodeError carries both a wrapped cause and the documented exit code the CLI should terminate with. main.go uses errors.As to extract it.

func (*ExitCodeError) Error

func (e *ExitCodeError) Error() string

Error implements error.

func (*ExitCodeError) Unwrap

func (e *ExitCodeError) Unwrap() error

Unwrap supports errors.Is / errors.As.

Jump to

Keyboard shortcuts

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