tailscale

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

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

func New(opts Options) (*Exposer, error)

New returns an Exposer. API and Runner are required.

func (*Exposer) Plan

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.

func (*Exposer) Release

func (e *Exposer) Release(ctx context.Context, p core.Preview) error

Release removes the tailnet nodes of preview p: every device whose short name equals p.ID exactly and that carries Tag, connected or not. Nothing matching is success, so Release is idempotent. A failing delete does not stop the others; all failures are returned joined.

type Options

type Options struct {
	// API is the Tailscale API client.
	API API
	// Runner runs the local tailscale CLI.
	Runner execx.Runner
}

Options configures an Exposer.

Directories

Path Synopsis
Package api is a small client for the Tailscale HTTP API (v2).
Package api is a small client for the Tailscale HTTP API (v2).

Jump to

Keyboard shortcuts

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