Documentation
¶
Overview ¶
Package tailscale implements core.Exposer with a Tailscale sidecar container: each preview joins the tailnet as its own node and forwards the exposed service ports.
It talks to the Tailscale control plane through the api subpackage and reads the tailnet domain from the local tailscale CLI. It must not import internal/host/*.
Index ¶
Constants ¶
const ( // Image is the pinned sidecar image. Never use latest/stable: the // TS_SERVE_CONFIG format is covered by a golden test for this version. Image = "tailscale/tailscale:v1.104.4" // SidecarService is the compose service name of the sidecar. SidecarService = "provr-ts" // StateVolume is the per-preview named volume holding the node identity. StateVolume = "provr-ts-state" // Tag is the ACL tag given to every preview node and its auth keys. Tag = "tag:provr" // EnvFileName is the 0600 env file (in the preview dir) holding TS_AUTHKEY. EnvFileName = "provr-ts.env" // ServeFileName is the serve config file (in the preview dir). ServeFileName = "provr-ts-serve.json" // StateDir is the state path inside the sidecar container. StateDir = "/var/lib/tailscale" // ServeConfigPath is the serve config path inside the sidecar container. ServeConfigPath = "/config/serve.json" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API interface {
CreateKey(ctx context.Context, spec api.KeySpec) (api.Key, error)
ListDevices(ctx context.Context) ([]api.Device, error)
DeleteDevice(ctx context.Context, id string) error
}
API is the subset of the Tailscale API client the exposer uses (satisfied by *api.Client).
type Exposer ¶
type Exposer struct {
// contains filtered or unexported fields
}
Exposer exposes previews on the tailnet through a Tailscale sidecar.
func (*Exposer) Plan ¶
func (e *Exposer) Plan(ctx context.Context, p core.Preview, ports []core.ServicePort) (core.ComposeFragment, []core.Endpoint, error)
Plan implements the planning half of core.Exposer. It validates its input, resolves the tailnet domain, makes sure no stale node of this preview blocks the hostname, mints a single-use auth key when the node must join, and returns the sidecar compose fragment plus the endpoints.
A device is "this preview" when its short name equals p.ID exactly and it carries Tag; "<id>-N" nodes (name collisions) and untagged nodes are never touched. If any matching device is connected to control, the preview is already joined: nothing is deleted, no key is minted and the fragment has no env file (the saved state in the state volume keeps the identity). When several matching devices exist and one is connected, all are left alone. Otherwise every matching (stale) device is deleted before the key is minted, so the new node gets the plain hostname.
The key only ever appears in the env file's Content (mode 0600); errors wrap API errors with context and never include it.