Documentation
¶
Overview ¶
Package localmode holds the pieces shared by the CLI's dev verb and the control plane's local-instance behavior.
Index ¶
- Constants
- Variables
- func AdminFilePath(dataDir string) string
- func AppURL(host string, httpPort int) string
- func ClearState(dataDir string)
- func DashboardURL(port int) string
- func DetectDocker(env DockerEnv) (string, error)
- func DockerFix(goos string, tried []string) string
- func DockerSocketCandidates(env DockerEnv) []string
- func Enabled(getenv func(string) string) bool
- func LoopbackFree(port int) bool
- func RequestReset(dataDir string) error
- func ResetMarkerPath(dataDir string) string
- func ResetRequested(dataDir string) bool
- func StateFilePath(dataDir string) string
- func ValidateListenAddr(addr string) error
- func Wipe(dataDir string) error
- func WriteState(st State) error
- type Admin
- type DockerEnv
- type PortFree
- type Ports
- type State
Constants ¶
const ( // EnvEnabled turns a control plane into a loopback-only local instance. EnvEnabled = "APP_LOCAL_MODE" // EnvSupervised tells the control plane a parent will relaunch it after a reset exit. EnvSupervised = "APP_RESTART_SUPERVISED" )
const (
// DefaultDashboardPort matches the CLI's default API address.
DefaultDashboardPort = 8080
)
Variables ¶
var ErrDockerUnreachable = errors.New("docker is not reachable")
ErrDockerUnreachable is returned when no candidate socket accepts a connection.
Functions ¶
func AdminFilePath ¶
AdminFilePath is where the generated admin credential is kept, mode 0600.
func AppURL ¶
AppURL is the address of an app served on host by an HTTP ingress listening on httpPort.
func DashboardURL ¶
DashboardURL is the dashboard address for a loopback port.
func DetectDocker ¶
DetectDocker returns the first socket that exists and accepts a connection.
func DockerSocketCandidates ¶
DockerSocketCandidates lists engine sockets in preference order: explicit settings first, then Docker Desktop's per-user sockets, then the system default.
func LoopbackFree ¶
LoopbackFree is the real PortFree: a listen-and-close probe.
func ResetMarkerPath ¶
ResetMarkerPath is the file whose presence asks the supervisor to wipe the data dir on the next relaunch.
func ResetRequested ¶
ResetRequested reports whether a reset marker is present.
func StateFilePath ¶
StateFilePath is where the running supervisor records its pid and URLs.
func ValidateListenAddr ¶
ValidateListenAddr rejects a dashboard listen address that is reachable beyond this machine.
Types ¶
type DockerEnv ¶
type DockerEnv struct {
Getenv func(string) string
Exists func(path string) bool
Dial func(socketPath string) error
GOOS string
}
DockerEnv is the slice of the process environment socket detection reads.
func RealDockerEnv ¶
RealDockerEnv is DockerEnv backed by the running process.
type State ¶
type State struct {
PID int `json:"pid"`
DataDir string `json:"data_dir"`
Dashboard string `json:"dashboard_url"`
HTTPPort int `json:"http_port"`
HTTPSPort int `json:"https_port"`
Started time.Time `json:"started"`
}
State is what a running supervisor records so stop and status can find it.