localmode

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package localmode contains the standalone CLI's local-mode contract.

Index

Constants

View Source
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

func DevStatePath() (string, error)

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 Command

type Command struct {
	Name string
	Args []string
	Env  []string
}

Command describes an external process invocation.

type CommandRunner

type CommandRunner interface {
	Run(ctx context.Context, name string, args ...string) ([]byte, error)
}

CommandRunner runs an external command.

type CommandRunnerFunc

type CommandRunnerFunc func(ctx context.Context, name string, args ...string) ([]byte, error)

CommandRunnerFunc adapts a function into a CommandRunner.

func (CommandRunnerFunc) Run

func (f CommandRunnerFunc) Run(ctx context.Context, name string, args ...string) ([]byte, error)

Run executes f.

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

func DevStateFromInfo(info Info) DevState

DevStateFromInfo maps server-owned local metadata into the legacy state file.

type DockerRunner

type DockerRunner interface {
	Run(ctx context.Context, command Command) ([]byte, error)
}

DockerRunner runs Docker commands for the local-mode environment.

type DockerRunnerFunc

type DockerRunnerFunc func(context.Context, Command) ([]byte, error)

DockerRunnerFunc adapts a function into a DockerRunner.

func (DockerRunnerFunc) Run

func (f DockerRunnerFunc) Run(ctx context.Context, command Command) ([]byte, error)

Run executes f.

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) GoString

func (i Info) GoString() string

GoString returns local-mode metadata with secret-bearing fields redacted.

func (Info) PSQLCommandHint

func (i Info) PSQLCommandHint() string

PSQLCommandHint returns a POSIX-shell-safe psql invocation for the default local database.

func (Info) String

func (i Info) String() string

String returns local-mode metadata with secret-bearing fields redacted.

type Option

type Option func(*Service)

Option configures a Service.

func WithDialTCP

func WithDialTCP(dialTCP func(context.Context, string) error) Option

WithDialTCP replaces TCP service probing.

func WithDockerRunner

func WithDockerRunner(runner DockerRunner) Option

WithDockerRunner replaces the Docker command runner.

func WithEnvironment

func WithEnvironment(environ func() []string, getenv func(string) string) Option

WithEnvironment replaces process environment access.

func WithHealthURL

func WithHealthURL(rawURL string) Option

WithHealthURL replaces the health URL used while waiting for startup.

func WithImage added in v0.0.4

func WithImage(image string) Option

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

func WithTempDir(tempDir string) Option

WithTempDir replaces the temporary directory used for the Compose file.

func WithTiming

func WithTiming(waitTimeout, pollInterval, infoTimeout time.Duration) Option

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

func (s Service) Doctor(ctx context.Context, w io.Writer) error

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.

func (Service) Reset

func (s Service) Reset(ctx context.Context, w io.Writer) error

Reset resets local-mode data in place through the running server container.

func (Service) Restart

func (s Service) Restart(ctx context.Context, w io.Writer) error

Restart restarts the local Volcano Docker stack while preserving data.

func (Service) Start

func (s Service) Start(ctx context.Context, w io.Writer) error

Start starts the local Volcano Docker stack.

func (Service) Status

func (s Service) Status(ctx context.Context, w io.Writer) error

Status displays the local Volcano Docker stack status.

func (Service) Stop

func (s Service) Stop(ctx context.Context, w io.Writer, clean bool) error

Stop stops the local Volcano Docker stack.

Jump to

Keyboard shortcuts

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