Documentation
¶
Index ¶
Constants ¶
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 ¶
var APIBaseURL = "https://api.instanode.dev"
APIBaseURL is the instanode.dev API base URL. Resolved at init from (in priority order):
- INSTANT_API_URL env var
- ~/.instant-config api_base_url
- Default: https://api.instanode.dev
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 ¶
ExecuteWithArgs runs the root command with an explicit args slice. The production callsite passes os.Args[1:]; tests pass a fixed slice.
func ExitCodeFor ¶
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 ¶
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) Unwrap ¶
func (e *ExitCodeError) Unwrap() error
Unwrap supports errors.Is / errors.As.