Documentation
¶
Overview ¶
Package localmode contains the standalone CLI's local-mode contract.
Index ¶
- Constants
- func DevStatePath() (string, error)
- func InfoCommandArgs() []string
- type Command
- type CommandRunner
- type CommandRunnerFunc
- type DevState
- type DockerRunner
- type DockerRunnerFunc
- type Info
- type Option
- func WithDialTCP(dialTCP func(context.Context, string) error) Option
- func WithDockerRunner(runner DockerRunner) Option
- func WithEnvironment(environ func() []string, getenv func(string) string) Option
- func WithHealthURL(rawURL string) Option
- func WithImage(image string) Option
- func WithTempDir(tempDir string) Option
- func WithTiming(waitTimeout, pollInterval, infoTimeout time.Duration) Option
- type Service
- func (s Service) Doctor(ctx context.Context, w io.Writer) error
- func (s Service) Reset(ctx context.Context, w io.Writer) error
- func (s Service) Restart(ctx context.Context, w io.Writer) error
- func (s Service) Start(ctx context.Context, w io.Writer) error
- func (s Service) Status(ctx context.Context, w io.Writer) error
- func (s Service) Stop(ctx context.Context, w io.Writer, clean bool) error
Constants ¶
const DeviceClientID = "devcli_dcc913b9786f9ef2825b861c"
DeviceClientID is the deterministic OAuth device client the local-mode server recognizes. Callers issue it directly when the CLI is targeting a local API.
Variables ¶
This section is empty.
Functions ¶
func DevStatePath ¶
DevStatePath returns the on-disk path for local development state.
func InfoCommandArgs ¶
func InfoCommandArgs() []string
InfoCommandArgs returns the docker arguments used to fetch local-mode metadata.
Types ¶
type CommandRunner ¶
type CommandRunner interface {
Run(ctx context.Context, name string, args ...string) ([]byte, error)
}
CommandRunner runs an external command.
type CommandRunnerFunc ¶
CommandRunnerFunc adapts a function into a CommandRunner.
type DevState ¶
type DevState struct {
JWTSecret string `json:"jwt_secret"`
EncryptionKey string `json:"encryption_key"`
AnonKeySecret string `json:"anon_key_secret"`
ServiceKeySecret string `json:"service_key_secret"`
UserID string `json:"user_id"`
AuthUserID string `json:"auth_user_id,omitempty"`
UserToken string `json:"user_token,omitempty"`
ProjectID string `json:"project_id"`
AnonKey string `json:"anon_key"`
ServiceKey string `json:"service_key"`
DatabaseURL string `json:"database_url"`
RedisURL string `json:"redis_url"`
}
DevState is the local development state file shape used by the old CLI.
func DevStateFromInfo ¶
DevStateFromInfo maps server-owned local metadata into the legacy state file.
type DockerRunner ¶
DockerRunner runs Docker commands for the local-mode environment.
type DockerRunnerFunc ¶
DockerRunnerFunc adapts a function into a DockerRunner.
type Info ¶
type Info struct {
APIURL string `json:"api_url"`
ProjectID string `json:"project_id"`
ProjectName string `json:"project_name"`
UserID string `json:"user_id"`
AuthUserID string `json:"auth_user_id"`
AuthUserEmail string `json:"auth_user_email"`
UserToken string `json:"user_token"`
AnonKey string `json:"anon_key"`
ServiceKey string `json:"service_key"`
DefaultDatabaseName string `json:"default_database_name"`
DefaultDatabaseRegion string `json:"default_database_region"`
DefaultDatabasePostgresVersion string `json:"default_database_postgres_version"`
DatabaseURL string `json:"database_url"`
RedisURL string `json:"redis_url"`
JWTSecret string `json:"jwt_secret"`
EncryptionKey string `json:"encryption_key"`
AnonKeySecret string `json:"anon_key_secret"`
ServiceKeySecret string `json:"service_key_secret"`
}
Info is the local-mode metadata returned by the Volcano server container. It contains local credentials; avoid logging it directly. Accidental fmt output through String and GoString redacts secret-bearing fields.
func FetchInfo ¶
func FetchInfo(ctx context.Context, runner CommandRunner) (Info, error)
FetchInfo returns local-mode metadata from the running Volcano server container. Callers should pass a context with a timeout.
func (Info) PSQLCommandHint ¶
PSQLCommandHint returns a POSIX-shell-safe psql invocation for the default local database.
type Option ¶
type Option func(*Service)
Option configures a Service.
func WithDialTCP ¶
WithDialTCP replaces TCP service probing.
func WithDockerRunner ¶
func WithDockerRunner(runner DockerRunner) Option
WithDockerRunner replaces the Docker command runner.
func WithEnvironment ¶
WithEnvironment replaces process environment access.
func WithHealthURL ¶
WithHealthURL replaces the health URL used while waiting for startup.
func WithImage ¶ added in v0.0.4
WithImage sets an explicit local-mode server image, taking precedence over the VOLCANO_IMAGE environment variable, any project .env.local value, and the bundled default. An empty value is ignored. An explicitly selected image is never pulled: it must already exist locally (see Start's pre-flight check).
func WithTempDir ¶
WithTempDir replaces the temporary directory used for the Compose file.
func WithTiming ¶
WithTiming replaces local-mode wait durations.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service performs local-mode environment workflows.
func NewService ¶
func NewService(deps cliruntime.Deps, opts ...Option) Service
NewService returns a local-mode environment service.
func (Service) Doctor ¶ added in v0.8.0
Doctor runs local-development preflight checks and reports actionable remediation. It probes for a Docker-compatible engine and Docker Compose v2 (capability, not a specific brand) and returns an error when a required prerequisite is missing so scripts and CI can gate on the exit code.