Documentation
¶
Index ¶
- Constants
- func ConfigDir() string
- func DaemonPIDPath() string
- func DataDir() string
- func DisplayHost(addr string) string
- func ExpandEnv(env map[string]string, base func(string) (string, bool)) map[string]string
- func GatewayPort(n int) *int
- func InternalLogPath(name string) string
- func LogPath(name string) string
- func ProjectGroupName(dir string) string
- func ReAdoptServices(services map[string]*ServiceState, recognise func(name string, pid int) bool)
- func RegistryPath() string
- func RemoveService(src Source, name string) error
- func Resolve(dir string, global bool) (*Registry, Source, error)
- func SafeFileName(name string) bool
- func SaveGatewayExpose(src Source, names []string, exposed bool) error
- func SaveProject(dir string, p *ProjectConfig) error
- func SaveRegistry(path string, reg *Registry) error
- func SaveServiceEdit(src Source, oldName, newName, command, cwd, group string) error
- func SaveState(path string, s *State) error
- func SaveTargetEdit(src Source, oldName, newName string, members []string) error
- func SaveTunnel(src Source, t TunnelConfig) (string, error)
- func SocketPath() string
- func SortedTargetNames(targets map[string][]string) []string
- func StatePath() string
- func StoredCWD(src Source, cwd string) string
- func StoredGroup(src Source, name string) string
- func ValidateName(kind, name string) error
- type GatewayConfig
- func (g GatewayConfig) Addr() string
- func (g *GatewayConfig) Defaults() GatewayConfig
- func (g GatewayConfig) ExposedSet() []string
- func (g GatewayConfig) LocalAllowlistApplies() bool
- func (g GatewayConfig) LocalLinksByPath(host string) bool
- func (g *GatewayConfig) SetExposed(names []string, exposed bool) bool
- func (g *GatewayConfig) Validate() error
- type GatewayRoute
- type GatewayState
- type ProjectConfig
- type ProjectServiceConfig
- type Registry
- type ServiceConfig
- type ServiceState
- type ServiceStatus
- type Source
- type State
- type TunnelConfig
- type TunnelState
Constants ¶
const ( PostureAuto = "auto" PosturePublished = "published" AuthAuto = "auto" AuthAlways = "always" AuthNone = "none" ModeSubdomain = "subdomain" ModePath = "path" HostUpstream = "upstream" HostPreserve = "preserve" )
Gateway posture, auth and Host-header settings. The zero value of each means "unset", and Defaults fills it in — so an absent gateway: block and an empty one behave identically.
const DefaultGatewayPort = 7788
DefaultGatewayPort is where the gateway listens when the config says nothing. A stable default matters: it is what makes a shared link keep working across restarts, so it is the behaviour of an absent key rather than of port 0.
const MaxGroupLen = 128
MaxGroupLen caps a group label, for every writer that validates one. Generous — a project directory name can be long — but bounded: this is a label drawn on one row of a pane at most 47 columns wide, so an unbounded one only makes a config file unreadable.
Counted in **characters, not bytes**, and every enforcer has to agree on that: the TUI's input limit counts runes, so a byte comparison elsewhere made the same string pass in one place and fail in the other — 128 Cyrillic characters are 256 bytes. Characters is also the unit the rationale is in, since what bounds this is how much fits on a row.
Shared so the MCP server's refusal and the TUI editor's input limit are the same number. They were 128 and 512, which made the same field's limit depend on who was writing it.
const ProjectFileName = "devrun.yaml"
const ProviderCloudflare = "cloudflare"
ProviderCloudflare is the only tunnel provider devrun drives. A second one would want an abstraction; one does not.
const ServicePlaceholder = "{service}"
ServicePlaceholder is what gateway.public_hostname substitutes a service name for. Exactly one, so recovering the name from a request's Host is a prefix and suffix strip with nothing to disambiguate.
Variables ¶
This section is empty.
Functions ¶
func ConfigDir ¶
func ConfigDir() string
ConfigDir returns ~/.config/devrun (or $XDG_CONFIG_HOME/devrun).
func DaemonPIDPath ¶
func DaemonPIDPath() string
func DataDir ¶
func DataDir() string
DataDir returns ~/.local/share/devrun (or $XDG_DATA_HOME/devrun).
func DisplayHost ¶ added in v0.5.0
DisplayHost turns a listen address into one a person can open.
A wildcard bind is announced as 0.0.0.0:<port>, which is where the gateway listens but not somewhere to go. Only presentation uses this: Posture reads the real address, and rewriting it there would report a wildcard bind as local.
func ExpandEnv ¶ added in v0.5.0
ExpandEnv resolves ${NAME} references in a service's env values against base, returning a new map. The input is not modified.
Values are literal today, so nothing can refer to anything — which is why DEVRUN_URL_<SERVICE> cannot reach a framework that filters env by prefix. Vite exposes only VITE_-prefixed variables to client code, Create React App only REACT_APP_, and devrun cannot know which. The bridge belongs in config:
env:
VITE_API_URL: "${DEVRUN_URL_API}"
Expansion is deliberately narrow:
- ${NAME} only. Bare $NAME is left alone, because env values are full of literal dollars — passwords, awk scripts, jq filters — and silently eating them would be worse than not expanding at all.
- $$ is a literal $, the escape for a value that really wants ${...}.
- An unset name expands to empty rather than erroring. A service whose URL does not exist yet should start with the variable blank, not fail.
- base is the inherited environment plus what devrun injects. Entries in this map cannot see each other: it is a map, so Go's iteration order is random, and sibling references would resolve differently run to run.
func GatewayPort ¶ added in v0.5.0
GatewayPort is a port literal as GatewayConfig.Port wants it. `port: 0` and an absent `port:` mean different things, so the field is a pointer and a literal needs somewhere to live.
func InternalLogPath ¶ added in v0.5.0
InternalLogPath is where a log devrun itself owns is kept — the gateway's stderr, cloudflared's output — in a subdirectory of the same logs directory, where anyone looking for logs will still find it.
A subdirectory rather than a name convention, because the convention cannot be enforced where it matters. Spelling these as LogPath("gateway") put them in the user's namespace, where a service called `gateway` — an ordinary thing to run — shared the file: its output was quoted back as the gateway's reason for failing to start, and `devrun logs gateway` interleaved the two. A "_gateway" prefix did not fix it either: the load-bearing check on a name that becomes a path is SafeFileName, not ValidateName, and SafeFileName accepts a leading underscore, so a hand-edited devrun.yaml reached it again.
SafeFileName does reject '/' and '\'. It is applied by startService before a name becomes a path that is written, and by ops.Logs before one is read — both, because a guard on only the writers left `devrun logs devrun/gateway` handing this file back as though a service had produced it.
func LogPath ¶
LogPath is where a *service's* output is kept. The name comes from the user, so it shares a directory with every other service's log and nothing else may claim a name in here — see InternalLogPath.
func ProjectGroupName ¶ added in v0.5.0
ProjectGroupName is the group a service in dir's devrun.yaml inherits when it names none of its own: the file's `name:`, or the sanitised directory name when it does not set one. The same value ToServiceConfigs would apply, for callers that hold only the derived ServiceConfigs and need the default back — the TUI's editor, mirroring a cleared group field without re-resolving the whole config.
A read error also yields the directory name. That is LoadProject's default for a *missing* `name:` but not its behaviour on a parse or permission error, which it propagates — so on a broken file this answers with a plausible group rather than the real one. Acceptable only because every caller runs against a file that has just loaded successfully; it is not a general-purpose reader.
func ReAdoptServices ¶
func ReAdoptServices(services map[string]*ServiceState, recognise func(name string, pid int) bool)
ReAdoptServices decides, for each service with a recorded pid, whether that process is still the one devrun started. Alive and recognised → StatusRunning with ReAdopted set; anything else → StatusCrashed with the pid cleared. Modifies the map in place.
recognise is asked only about pids that are alive, and a nil recognise keeps the liveness-only behaviour. It must answer true whenever it cannot tell: see the daemon's recogniseService for why a false negative is the more expensive mistake.
The liveness probe treats EPERM as dead, unlike the one used for devrun's own children. That is deliberate here. EPERM means the process belongs to another user, which a service devrun spawned never does — so it is a stranger who inherited the pid, and refusing to adopt it is the point.
func RegistryPath ¶
func RegistryPath() string
func RemoveService ¶
RemoveService deletes a service from whichever config src points at: the project devrun.yaml when src.IsLocal(), otherwise the global registry.
It errors when the named service is not defined in that config. Notifying a running daemon (so it evicts the service from its in-memory map) is the caller's responsibility.
func Resolve ¶
Resolve determines which service registry is active for a command run in dir.
When global is false and dir contains a devrun.yaml, that file is loaded and converted to an in-memory Registry, and the returned Source points at it. Otherwise the global registry (~/.config/devrun/services.yaml) is returned with an empty Source. Project services are never written to the global registry, so it contains only services registered with `devrun add`.
func SafeFileName ¶ added in v0.4.0
SafeFileName reports whether name can be used as the base of a file name — as a service's log file is — without escaping its directory. It is the looser, load-bearing check applied wherever a name becomes a path, so it holds even for names that never went through ValidateName (a hand-edited devrun.yaml, a config from before the rule).
func SaveGatewayExpose ¶ added in v0.5.0
SaveGatewayExpose adds or removes services from the gateway allowlist in whichever config src points at — the project devrun.yaml when src.IsLocal(), otherwise the global registry. It mirrors SaveTargetEdit: an allowlist is a named set of services, and `gateway expose` is as much a config edit as `target add` is.
Persisting matters beyond convenience. The allowlist is what may leave the machine; if it lived only in the running gateway, the next `gateway up` would read the file, see something different, and silently restart without it.
func SaveProject ¶
func SaveProject(dir string, p *ProjectConfig) error
SaveProject writes p to devrun.yaml in dir. The file is re-marshalled from the in-memory structure, so hand-written comments and key ordering are not preserved.
func SaveRegistry ¶
SaveRegistry writes the registry to path, creating parent directories as needed.
func SaveServiceEdit ¶
SaveServiceEdit changes an existing service's name, command, working directory and group, then persists the result to whichever config src points at: the project devrun.yaml when src.IsLocal(), otherwise the global registry.
oldName identifies the service to edit. newName and command must be non-empty (after trimming); newName may equal oldName but must not collide with a different existing service. For a project file cwd is stored relative to src.Dir (and dropped when it is the project root); for the global registry it is stored as given. An empty group is stored as empty — which for a project service means it goes back to inheriting the project's name — so clearing the field is a real edit, not a no-op. The remaining fields (env, desc, port) are preserved.
func SaveTargetEdit ¶
SaveTargetEdit renames a target and/or replaces its member list, persisting to whichever config src points at: the project devrun.yaml when src.IsLocal(), otherwise the global registry.
oldName identifies the target to edit. newName must be non-empty (after trimming); it may equal oldName but must not collide with a different target. members is stored sorted and de-duplicated; an empty list is allowed.
func SaveTunnel ¶ added in v0.5.0
func SaveTunnel(src Source, t TunnelConfig) (string, error)
SaveTunnel writes the tunnel block to whichever config src points at — the project devrun.yaml when src.IsLocal(), otherwise the global registry — and returns the path it wrote, so the caller can say which file it touched.
This is the one place a lifecycle command writes config, and it is a deliberate exception: it records an answer the user has just typed at a prompt, rather than inferring one. `gateway expose` already writes to the active config the way `target add` does.
func SocketPath ¶
func SocketPath() string
func SortedTargetNames ¶
SortedTargetNames returns the target names in targets, sorted alphabetically.
func StoredCWD ¶ added in v0.5.0
StoredCWD is the value SaveServiceEdit would persist for cwd in the config src points at: relative to the project dir for a devrun.yaml, and empty when it is the project root; as given for the global registry.
For callers deciding whether an edit actually changed anything. The TUI's form shows a project service's *resolved absolute* cwd, so the field and the file disagree by construction — blanking the field is a no-op on disk, and comparing the raw text would read it as a change.
func StoredGroup ¶ added in v0.5.0
StoredGroup is the group the service called name sets for *itself* in the config src points at, or "" when it sets none.
Distinct from ServiceConfig.Group, which for a project service has already had the project's name applied as a default by ToServiceConfigs. Anything that needs to tell "inherits the project's name" from "explicitly set to the project's name" — the editor, so it can round-trip the field rather than rewriting it — has to read the file, because the derived value cannot distinguish them.
A service that is not in the config, or a config that will not load, reads as "" the same way a service with no group does: the caller is prefilling a form, and an empty field is the safe answer.
func ValidateName ¶ added in v0.4.0
ValidateName checks a new service or target name. kind ("service" or "target") only shapes the error message.
Types ¶
type GatewayConfig ¶ added in v0.5.0
type GatewayConfig struct {
// Port distinguishes three cases, which an int could not: absent is
// DefaultGatewayPort, 0 is "any free port, the kernel picks", and anything
// else is itself. Port 0 is how you run two projects at once without
// choosing numbers by hand.
Port *int `yaml:"port,omitempty" json:"port,omitempty"`
Bind string `yaml:"bind,omitempty" json:"bind,omitempty"`
Posture string `yaml:"posture,omitempty" json:"posture,omitempty"`
Mode string `yaml:"mode,omitempty" json:"mode,omitempty"`
Auth string `yaml:"auth,omitempty" json:"auth,omitempty"`
HostHeader string `yaml:"host_header,omitempty" json:"host_header,omitempty"`
// PublicHostname is how a published service is addressed, as a template
// with one {service} placeholder — "{service}-devrun.example.com". Unset,
// the gateway puts the service's name in front of whatever host it was
// reached on, which is what *.localhost needs locally.
//
// It exists because that prepend cannot be used when published. A
// Cloudflare Universal SSL certificate covers the apex and one wildcard
// level, so reaching the gateway at devrun.example.com and linking to
// web.devrun.example.com produces a name no certificate covers — the TLS
// handshake is refused outright, not merely distrusted. A template lets
// the service names live wherever the certificate reaches.
PublicHostname string `yaml:"public_hostname,omitempty" json:"public_hostname,omitempty"`
Expose []string `yaml:"expose,omitempty" json:"expose,omitempty"`
Routes map[string]GatewayRoute `yaml:"routes,omitempty" json:"routes,omitempty"`
}
GatewayConfig is the gateway: block of a devrun.yaml or services.yaml.
Every field has a working default, so `devrun gateway up` with no block at all serves every running service on 127.0.0.1:7788.
func (GatewayConfig) Addr ¶ added in v0.5.0
func (g GatewayConfig) Addr() string
Addr is the address the gateway listens on. Call it on the result of Defaults, which is what guarantees Port is set.
func (*GatewayConfig) Defaults ¶ added in v0.5.0
func (g *GatewayConfig) Defaults() GatewayConfig
Defaults returns a copy with every unset field filled in. A nil receiver is a valid input and yields the all-defaults gateway.
func (GatewayConfig) ExposedSet ¶ added in v0.5.0
func (g GatewayConfig) ExposedSet() []string
ExposedSet is the allowlist as a set, sorted for a stable status output.
func (GatewayConfig) LocalAllowlistApplies ¶ added in v0.5.0
func (g GatewayConfig) LocalAllowlistApplies() bool
LocalAllowlistApplies reports whether the gateway withholds a service from a request made on this machine.
Notably a running tunnel does not: a request arriving through one carries the public hostname, which fails the gateway's own hostIsSelf check and is treated as published on that evidence, while a browser at localhost is not. So publishing takes a withheld service off the internet without taking it off your own machine.
Snapshot used to carry a flag that forced published for every request once devrun had started a tunnel. Writing this rule to match it withheld local addresses the gateway serves; the flag was never set outside a test and has since been deleted.
internal/gateway's Posture is where this is really decided; TestLocalAllowlistMatchesTheGatewaysPosture in internal/ops holds the two together.
func (GatewayConfig) LocalLinksByPath ¶ added in v0.5.0
func (g GatewayConfig) LocalLinksByPath(host string) bool
LocalLinksByPath reports whether a service at this gateway is reached by a path rather than a hostname of its own, for someone browsing from this machine.
It mirrors internal/gateway's pathLinks for the local case, where the request always counts as coming from here and the public_hostname template therefore never applies — that template names where a service lives when published, which is not where it lives at localhost:7788.
That package does not import this one, so nothing in the compiler holds the two together. TestLocalLinksMatchTheGatewaysOwnChoice in internal/ops does, that being the one package importing both.
func (*GatewayConfig) SetExposed ¶ added in v0.5.0
func (g *GatewayConfig) SetExposed(names []string, exposed bool) bool
SetExposed adds or removes names from the allowlist, reporting whether anything changed. Removing a service the routes table mounts is refused by the caller, not here — this only edits the list.
func (*GatewayConfig) Validate ¶ added in v0.5.0
func (g *GatewayConfig) Validate() error
Validate rejects a gateway block that cannot mean anything, naming the key at fault. It is deliberately strict about the enums: a typo in `posture` would otherwise silently fall back to a weaker setting than the user asked for.
type GatewayRoute ¶ added in v0.5.0
type GatewayRoute struct {
Service string `yaml:"service" json:"service"`
Strip bool `yaml:"strip" json:"strip"`
}
GatewayRoute mounts a service at a path. It accepts two spellings in YAML:
"/api": api # shorthand
"/api": {service: api, strip: false}
Strip defaults to true, matching what path routing does without a table — the service knows nothing about being mounted under a prefix. strip: false is the production-parity opt-in: the backend keeps seeing /api/..., so a frontend's relative URLs behave the same in dev, published and in production.
func (*GatewayRoute) UnmarshalYAML ¶ added in v0.5.0
func (r *GatewayRoute) UnmarshalYAML(value *yaml.Node) error
UnmarshalYAML accepts the shorthand as well as the full mapping.
type GatewayState ¶ added in v0.5.0
type GatewayState struct {
PID int `json:"pid"`
Addr string `json:"addr"`
Token string `json:"token"`
Config GatewayConfig `json:"config"`
}
GatewayState is the running gateway, recorded so a replacement daemon can take it back.
The gateway is spawned into its own session and never waited on, so it outlives the daemon on every path except SIGTERM — which is deliberate, the same as for services: `devrun daemon restart` should not drop a published URL. Without this record the replacement daemon had no handle on it, and the gateway became unstoppable and invisible while still holding its port.
Token is here because it cannot be re-derived: the running child was given it at startup and a new daemon cannot change its mind. It is why state.json is written 0600.
type ProjectConfig ¶
type ProjectConfig struct {
Name string `yaml:"name,omitempty"`
Services map[string]*ProjectServiceConfig `yaml:"services"`
// Targets maps a target name to the service names it groups. See
// Registry.Targets — the semantics are identical for a project file.
Targets map[string][]string `yaml:"targets,omitempty"`
// Gateway configures the local HTTP gateway for this project.
Gateway *GatewayConfig `yaml:"gateway,omitempty"`
// Tunnel configures publishing. Absent means cloudflared is never looked
// for; publishing is optional, and so is the dependency.
Tunnel *TunnelConfig `yaml:"tunnel,omitempty"`
}
ProjectConfig is the top-level structure of devrun.yaml.
func LoadProject ¶
func LoadProject(dir string) (*ProjectConfig, error)
LoadProject reads devrun.yaml from dir. Returns nil, nil if the file does not exist. If Name is empty it defaults to the sanitised base name of dir.
func (*ProjectConfig) ToServiceConfigs ¶
func (p *ProjectConfig) ToServiceConfigs(dir string) map[string]*ServiceConfig
ToServiceConfigs converts a ProjectConfig to ServiceConfig entries ready for the global registry. Relative CWD values are resolved against dir.
type ProjectServiceConfig ¶
type ProjectServiceConfig struct {
Command string `yaml:"command"`
CWD string `yaml:"cwd,omitempty"`
Env map[string]string `yaml:"env,omitempty"`
Desc string `yaml:"desc,omitempty"`
// Group sections this service in the dashboard. Empty inherits the
// project's name, which is what every service in a devrun.yaml got before
// this field existed — so a file that says nothing about groups behaves
// exactly as it did.
//
// An explicit group replaces that default rather than nesting inside it:
// groups are a flat set, so a project that groups some of its services
// simply shows the project's name as the header for the rest.
Group string `yaml:"group,omitempty"`
// Port overrides detection; see ServiceConfig.Port.
Port int `yaml:"port,omitempty"`
}
ProjectServiceConfig is a service entry in a devrun.yaml file.
func (*ProjectServiceConfig) Validate ¶
func (c *ProjectServiceConfig) Validate() error
Validate mirrors ServiceConfig.Validate for a devrun.yaml service entry.
type Registry ¶
type Registry struct {
Version string `yaml:"version"`
Services map[string]*ServiceConfig `yaml:"services"`
// Targets maps a target name to the service names it groups. A target is a
// named subset of services that can be started or stopped as a unit. Members
// that do not resolve to a known service are ignored at use time rather than
// rejected on load, so removing a service never breaks config parsing.
Targets map[string][]string `yaml:"targets,omitempty"`
// Gateway configures the local HTTP gateway. Absent means all defaults.
Gateway *GatewayConfig `yaml:"gateway,omitempty"`
// Tunnel configures publishing. Absent means cloudflared is never looked
// for; publishing is optional, and so is the dependency.
Tunnel *TunnelConfig `yaml:"tunnel,omitempty"`
}
Registry is the top-level structure of services.yaml.
func LoadRegistry ¶
LoadRegistry reads services.yaml. Returns an empty registry if the file does not exist.
func (*Registry) TargetMemberConfigs ¶
func (r *Registry) TargetMemberConfigs(name string) []*ServiceConfig
TargetMemberConfigs resolves the members of target name to their service definitions, in the order listed. Members that are not a known service in the registry are skipped, and a name listed more than once is only returned once. An unknown target name yields nil.
type ServiceConfig ¶
type ServiceConfig struct {
Name string `yaml:"name" json:"name"`
Command string `yaml:"command" json:"command"`
CWD string `yaml:"cwd,omitempty" json:"cwd,omitempty"`
Group string `yaml:"group,omitempty" json:"group,omitempty"`
Env map[string]string `yaml:"env,omitempty" json:"env,omitempty"`
Desc string `yaml:"desc,omitempty" json:"desc,omitempty"`
// Port overrides what the daemon detects. Detection is correct but not
// instant — it lags a service's start by up to one poll, and picks the
// lowest when a service holds several listeners — so this is the answer for
// a service the gateway must reach immediately or that runs a debugger
// alongside its app port.
Port int `yaml:"port,omitempty" json:"port,omitempty"`
}
ServiceConfig is the shared vocabulary across CLI, daemon, and config layer. YAML tags match the devrun.yaml and services.yaml schema. JSON tags are load bearing too: ServiceConfig crosses the wire as JSON in ipc.StartPayload and in the daemon re-exec handoff, so the field names must be pinned explicitly rather than left to default to the Go identifiers.
func (*ServiceConfig) Validate ¶
func (c *ServiceConfig) Validate() error
Validate reports whether a service definition is runnable. The dominant failure is a blank command: the daemon would otherwise hand `sh -c` an empty script, which exits 0 immediately and is reported as a clean one-shot run.
type ServiceState ¶
type ServiceStatus ¶
type ServiceStatus string
const ( StatusStopped ServiceStatus = "stopped" StatusStarting ServiceStatus = "starting" StatusRunning ServiceStatus = "running" StatusCrashed ServiceStatus = "crashed" StatusStopping ServiceStatus = "stopping" // StatusExited marks a process that terminated on its own with exit code 0 // (e.g. a one-shot command), as opposed to StatusCrashed (non-zero exit or // killed by signal) or StatusStopped (terminated by `devrun stop`). StatusExited ServiceStatus = "exited" )
func (ServiceStatus) IsLive ¶
func (s ServiceStatus) IsLive() bool
IsLive reports whether the process is (or should be) running — i.e. uptime, CPU, and memory are meaningful. Terminal states (stopped, exited, crashed) are not live.
type Source ¶
type Source struct {
// Local is the path to the project devrun.yaml when one is active, or "" when
// the global registry is in use.
Local string
// Dir is the directory the project devrun.yaml lives in. Empty for the global
// registry.
Dir string
}
Source describes where the active service registry for a command came from.
type State ¶
type State struct {
Version int `json:"version"`
Services map[string]*ServiceState `json:"services"`
Gateway *GatewayState `json:"gateway,omitempty"`
Tunnel *TunnelState `json:"tunnel,omitempty"`
// ActiveTargets maps a currently-started target to the member service names
// captured when it was started. `devrun target stop` consults this snapshot —
// not the live config — so editing a target's membership while it runs does
// not change what a later stop releases. A service is left running on stop if
// it still appears under another active target.
ActiveTargets map[string][]string `json:"active_targets,omitempty"`
}
type TunnelConfig ¶ added in v0.5.0
type TunnelConfig struct {
Provider string `yaml:"provider,omitempty" json:"provider,omitempty"`
// Name is the cloudflared tunnel to run. Empty means a quick tunnel.
Name string `yaml:"name,omitempty" json:"name,omitempty"`
// Hostname is what DNS points at that tunnel. devrun builds URLs from it
// and never creates the record.
Hostname string `yaml:"hostname,omitempty" json:"hostname,omitempty"`
}
TunnelConfig is the tunnel: block of a devrun.yaml or services.yaml. Absent means devrun never looks for cloudflared at all — publishing is optional, and so is the dependency.
Name and Hostname are separate because cloudflared keeps them separate: `cloudflared tunnel run --url <origin> <name>` identifies the tunnel by **name**, while the public **hostname** is a DNS CNAME pointing at it. Neither `tunnel info` nor `tunnel list` returns DNS routes, so devrun cannot derive one from the other. An earlier revision of the design used one field for both and would have passed a hostname where cloudflared wants a name.
func (*TunnelConfig) Defaults ¶ added in v0.5.0
func (t *TunnelConfig) Defaults() TunnelConfig
Defaults returns a copy with every unset field filled in. A nil receiver is valid and yields the all-defaults tunnel, which is a quick one.
func (TunnelConfig) IsQuick ¶ added in v0.5.0
func (t TunnelConfig) IsQuick() bool
IsQuick reports whether this configuration asks for a quick tunnel — a throwaway *.trycloudflare.com hostname that changes every run and needs no account, no DNS and no prior login.
func (*TunnelConfig) Validate ¶ added in v0.5.0
func (t *TunnelConfig) Validate() error
Validate rejects a tunnel block that cannot mean anything, naming the key at fault.
type TunnelState ¶ added in v0.5.0
type TunnelState struct {
PID int `json:"pid"`
Kind string `json:"kind"` // "named" | "quick"
// Origin is the gateway address cloudflared was pointed at, so a new
// gateway can tell whether it has actually moved.
Origin string `json:"origin"`
PublicURL string `json:"public_url"`
Config TunnelConfig `json:"config"`
}
TunnelState is the running cloudflared, recorded for the same reason GatewayState is: the process outlives the daemon on every exit path but SIGTERM, so without a record a replacement daemon could neither see it nor stop it, while it went on publishing.