Documentation
¶
Index ¶
- Constants
- func AddNetworkFlags(cmd *cobra.Command, nf *NetworkFlags)
- func BuildQuery(filter string, limit int, sort string, extra map[string]string) string
- func EnvURLs(env Env, serviceName string, localPort int) string
- func LoadToken() string
- func NewClusterCommand(nf *NetworkFlags) *cobra.Command
- func NewCollectionCommand(clientFn func() *Client, formatFn func() Format) *cobra.Command
- func NewConfigCommand() *cobra.Command
- func NewCronsCommand(clientFn func() *Client, formatFn func() Format) *cobra.Command
- func NewDaemonCommand() *cobra.Command
- func NewLoginCommand(clientFn func() *Client, formatFn func() Format) *cobra.Command
- func NewOperatorCommand(nf *NetworkFlags) *cobra.Command
- func NewRPCCommand(clientFn func() *Client, formatFn func() Format) *cobra.Command
- func NewRecordCommand(clientFn func() *Client, formatFn func() Format) *cobra.Command
- func NewSelfCommand(version string) *cobra.Command
- func NewStatusCommand(clientFn func() *Client, formatFn func() Format, nf *NetworkFlags) *cobra.Command
- func NewWhoamiCommand(clientFn func() *Client, formatFn func() Format) *cobra.Command
- func Print(w io.Writer, format Format, data json.RawMessage) error
- func ResolveToken(flagToken string) string
- func ResolveURL(flagURL string) string
- func SaveBaseConfig(cfg *BaseConfig) error
- func SaveToken(token string) error
- type BaseConfig
- type Client
- func (c *Client) Delete(path string) (json.RawMessage, int, error)
- func (c *Client) Do(method, path string, body any) (json.RawMessage, int, error)
- func (c *Client) Get(path string) (json.RawMessage, int, error)
- func (c *Client) Patch(path string, body any) (json.RawMessage, int, error)
- func (c *Client) Post(path string, body any) (json.RawMessage, int, error)
- type Env
- type EnvConfig
- type Format
- type NetworkFlags
Constants ¶
const DefaultOperatorNetworkDir = "k8s/networks"
DefaultOperatorNetworkDir is the path to the operator network YAMLs. Resolved relative to the user's checkout of ~/work/liquidity/operator.
Variables ¶
This section is empty.
Functions ¶
func AddNetworkFlags ¶
func AddNetworkFlags(cmd *cobra.Command, nf *NetworkFlags)
AddNetworkFlags registers --mainnet, --testnet, --devnet, --dev on the given command's persistent flags so they propagate to all subcommands. Skips any flag already registered on the command (e.g. PocketBase's built-in --dev) so it's safe to call after app.RootCmd is constructed.
func BuildQuery ¶
BuildQuery encodes query parameters for list endpoints.
func LoadToken ¶
func LoadToken() string
LoadToken reads the stored token from disk. Returns empty string (no error) if the file does not exist.
func NewClusterCommand ¶
func NewClusterCommand(nf *NetworkFlags) *cobra.Command
NewClusterCommand returns the `cluster` subcommand tree for managing Base HA groups. Uses the BASE_* env namespace per base-ha conventions.
func NewCollectionCommand ¶
NewCollectionCommand returns the `collection` subcommand tree.
func NewConfigCommand ¶
NewConfigCommand returns the `config` subcommand tree. Matches `lux config` shape.
func NewCronsCommand ¶
NewCronsCommand returns the `crons` subcommand tree.
func NewDaemonCommand ¶
NewDaemonCommand returns the `daemon` subcommand tree for managing the daemon process lifecycle. Works in two modes:
- Local: spawns/kills the process directly (default when no --env flag).
- K8s: delegates to kubectl for rollout management (when --env is set).
The daemon name is derived from os.Args[0] base name.
func NewLoginCommand ¶
NewLoginCommand returns the `login` subcommand.
func NewOperatorCommand ¶
func NewOperatorCommand(nf *NetworkFlags) *cobra.Command
NewOperatorCommand returns the `operator` subcommand tree for managing Liquidity K8s operator CRDs (liquid.network/v1alpha1).
func NewRPCCommand ¶
NewRPCCommand returns the `rpc` subcommand. Matches `lux rpc` shape: direct API call passthrough.
func NewRecordCommand ¶
NewRecordCommand returns the `record` subcommand tree.
func NewSelfCommand ¶
NewSelfCommand returns the `self` subcommand tree. Matches `lux self` shape: manages the binary install.
func NewStatusCommand ¶
func NewStatusCommand(clientFn func() *Client, formatFn func() Format, nf *NetworkFlags) *cobra.Command
NewStatusCommand returns the `status` subcommand. Matches `lux status` shape: shows daemon health, leader info, etc.
func NewWhoamiCommand ¶
NewWhoamiCommand returns the `whoami` subcommand.
func ResolveToken ¶
ResolveToken returns the token from (in priority order): 1. --token flag 2. $BASE_TOKEN env var 3. ~/.config/base/token file
func ResolveURL ¶
ResolveURL returns the server URL from (in priority order): 1. --url flag 2. $BASE_URL env var 3. http://127.0.0.1:8090
Types ¶
type BaseConfig ¶
type BaseConfig struct {
DefaultEnv string `json:"default_env"`
Envs map[string]EnvConfig `json:"envs"`
DefaultOrg string `json:"default_org"`
TokenPath string `json:"token_path"`
}
BaseConfig is the ~/.config/base/config.json schema.
func LoadBaseConfig ¶
func LoadBaseConfig() (*BaseConfig, error)
LoadBaseConfig reads config.json. Returns defaults if file is missing.
type Client ¶
Client is a thin HTTP client for the Base API.
func (*Client) Do ¶
Do executes a raw HTTP request against the Base API and returns the decoded JSON body. Non-2xx responses are returned as an error.
type Env ¶
type Env string
Env is a canonical environment name.
func (Env) DomainSuffix ¶
DomainSuffix returns the DNS zone suffix for service URLs.
func (Env) K8sContext ¶
K8sContext returns the GKE kubectl context for this env.
func (Env) K8sNamespace ¶
K8sNamespace returns the K8s namespace for this env.
type EnvConfig ¶
type EnvConfig struct {
ATSURL string `json:"ats_url,omitempty"`
BDURL string `json:"bd_url,omitempty"`
TAURL string `json:"ta_url,omitempty"`
IAMURL string `json:"iam_url,omitempty"`
}
EnvConfig holds per-environment service URLs.
type Format ¶
type Format string
Format is the output format.
func DetectFormat ¶
DetectFormat returns table if stdout is a TTY, json otherwise.
func ParseFormat ¶
ParseFormat returns the output format from a string.
type NetworkFlags ¶
NetworkFlags holds the mutually-exclusive --mainnet/--testnet/--devnet/--dev flags. Mirrors the lux/cli pattern: exactly one may be set.
func (*NetworkFlags) Resolve ¶
func (nf *NetworkFlags) Resolve() (Env, error)
Resolve returns the canonical Env. Rules:
- Exactly one flag set -> that env.
- No flags -> $LIQUIDITY_ENV, then $BASE_ENV, then default "local".
- More than one flag -> error.