Documentation
¶
Index ¶
- Variables
- func AllPeers(ctx context.Context, srv *Server) ([]types.Peer, error)
- func AuthMiddleware(srv *Server) func(http.Handler) http.Handler
- func Discover(ctx context.Context, srv *Server, toolName string) ([]types.Peer, error)
- func DiscoverVersion(ctx context.Context, srv *Server, toolName, minVersion string) ([]types.Peer, error)
- func ExecWith(ctx context.Context, vars map[string]string, argv []string) error
- func GetConfig(n *NodeClient, ctx context.Context, integration string, config any) error
- func GetPeerTools(ctx context.Context, srv *Server, tailscaleIP string) ([]types.Tool, error)
- func GetPeers(ctx context.Context, srv *Server) (map[key.NodePublic]*ipnstate.PeerStatus, error)
- func GetTailkitHostname(hostname string) string
- func GetTailkitPeer(ctx context.Context, srv *Server, hostname string) (*types.TailkitPeer, error)
- func Install(ctx context.Context, tool types.Tool) error
- func OnlinePeers(ctx context.Context, srv *Server) ([]types.Peer, error)
- func TailkitPeers(ctx context.Context, srv *Server) ([]types.TailkitPeer, error)
- func Uninstall(name string) error
- type CallerContextKey
- type CallerIdentity
- type ComposeClient
- func (cc *ComposeClient) Build(ctx context.Context, name string) (types.Job, error)
- func (cc *ComposeClient) Down(ctx context.Context, name string) (types.Job, error)
- func (cc *ComposeClient) Project(ctx context.Context, name string) (types.ComposeService, error)
- func (cc *ComposeClient) Projects(ctx context.Context) ([]types.ComposeService, error)
- func (cc *ComposeClient) Pull(ctx context.Context, name string) (types.Job, error)
- func (cc *ComposeClient) Restart(ctx context.Context, name string) (types.Job, error)
- func (cc *ComposeClient) Up(ctx context.Context, name, composefile string) (types.Job, error)
- type DockerClient
- func (dc *DockerClient) Available(ctx context.Context) (bool, error)
- func (dc *DockerClient) Compose() *ComposeClient
- func (dc *DockerClient) Config(ctx context.Context) (integrationsTypes.DockerConfig, error)
- func (dc *DockerClient) Container(ctx context.Context, id string) (container.InspectResponse, error)
- func (dc *DockerClient) Containers(ctx context.Context) ([]container.Summary, error)
- func (dc *DockerClient) Images(ctx context.Context) ([]image.Summary, error)
- func (dc *DockerClient) Logs(ctx context.Context, id string, tail int) (string, error)
- func (dc *DockerClient) Pull(ctx context.Context, ref string) (types.Job, error)
- func (dc *DockerClient) Remove(ctx context.Context, id string) (types.Job, error)
- func (dc *DockerClient) Restart(ctx context.Context, id string) (types.Job, error)
- func (dc *DockerClient) Start(ctx context.Context, id string) (types.Job, error)
- func (dc *DockerClient) Stop(ctx context.Context, id string) (types.Job, error)
- func (dc *DockerClient) Swarm() *SwarmClient
- type FilesClient
- func (fc *FilesClient) Config(ctx context.Context) (integrationsTypes.FilesConfig, error)
- func (fc *FilesClient) Download(ctx context.Context, remotePath, localPath string) error
- func (fc *FilesClient) List(ctx context.Context, dirPath string) ([]types.DirEntry, error)
- func (fc *FilesClient) Read(ctx context.Context, path string) (string, error)
- func (fc *FilesClient) Send(ctx context.Context, req types.SendRequest) (types.SendResult, error)
- func (fc *FilesClient) SendDir(ctx context.Context, req types.SendDirRequest) ([]types.SendResult, error)
- func (fc *FilesClient) Stat(ctx context.Context, path string) (types.FileStat, error)
- type FleetClient
- type FleetFilesClient
- func (ff *FleetFilesClient) Config(ctx context.Context) (map[string]integrationsTypes.FilesConfig, map[string]error)
- func (ff *FleetFilesClient) Download(ctx context.Context, path string, localPath string) (map[string]string, map[string]error)
- func (ff *FleetFilesClient) List(ctx context.Context, path string) (map[string][]types.DirEntry, map[string]error)
- func (ff *FleetFilesClient) Read(ctx context.Context, path string) (map[string]string, map[string]error)
- func (ff *FleetFilesClient) Send(ctx context.Context, req types.SendRequest) (map[string]types.SendResult, map[string]error)
- func (ff *FleetFilesClient) SendDir(ctx context.Context, req types.SendDirRequest) (map[string][]types.SendResult, map[string]error)
- func (ff *FleetFilesClient) Stat(ctx context.Context, path string) (map[string]types.FileStat, map[string]error)
- type FleetMetricsClient
- func (fm *FleetMetricsClient) All(ctx context.Context) (map[string]map[string]any, map[string]error)
- func (fm *FleetMetricsClient) CPU(ctx context.Context) (map[string]map[string]any, map[string]error)
- func (fm *FleetMetricsClient) Config(ctx context.Context) (map[string]integrationsTypes.MetricsConfig, map[string]error)
- func (fm *FleetMetricsClient) Memory(ctx context.Context) (map[string]map[string]any, map[string]error)
- type FleetVarsClient
- func (fv *FleetVarsClient) Config(ctx context.Context) (map[string]integrationsTypes.VarsConfig, map[string]error)
- func (fv *FleetVarsClient) List(ctx context.Context) (map[string]map[string]string, map[string]error)
- func (fv *FleetVarsClient) Set(ctx context.Context, key, value string) map[string]error
- type MetricsClient
- func (mc *MetricsClient) All(ctx context.Context) (map[string]any, error)
- func (mc *MetricsClient) Available(ctx context.Context) (bool, error)
- func (mc *MetricsClient) CPU(ctx context.Context) (map[string]any, error)
- func (mc *MetricsClient) Config(ctx context.Context) (integrationsTypes.MetricsConfig, error)
- func (mc *MetricsClient) Disk(ctx context.Context) ([]map[string]any, error)
- func (mc *MetricsClient) Host(ctx context.Context) (map[string]any, error)
- func (mc *MetricsClient) Memory(ctx context.Context) (map[string]any, error)
- func (mc *MetricsClient) Network(ctx context.Context) ([]map[string]any, error)
- func (mc *MetricsClient) Processes(ctx context.Context) ([]map[string]any, error)
- type NodeClient
- func (n *NodeClient) Docker() *DockerClient
- func (n *NodeClient) ExecJob(ctx context.Context, jobID string) (types.JobResult, error)
- func (n *NodeClient) ExecWait(ctx context.Context, jobID string) (types.JobResult, error)
- func (n *NodeClient) Files() *FilesClient
- func (n *NodeClient) HasTool(ctx context.Context, name string, minVersion string) (bool, error)
- func (n *NodeClient) Metrics() *MetricsClient
- func (n *NodeClient) Systemd() *SystemdClient
- func (n *NodeClient) Tools(ctx context.Context) ([]types.Tool, error)
- func (n *NodeClient) Vars(project, env string) *VarsClient
- type Server
- type ServerConfig
- type SwarmClient
- type SystemdClient
- func (sc *SystemdClient) Available(ctx context.Context) (bool, error)
- func (sc *SystemdClient) Config(ctx context.Context) (integrationsTypes.SystemdConfig, error)
- func (sc *SystemdClient) Disable(ctx context.Context, unit string) (types.Job, error)
- func (sc *SystemdClient) Enable(ctx context.Context, unit string) (types.Job, error)
- func (sc *SystemdClient) Journal(ctx context.Context, unit string, lines int) ([]map[string]any, error)
- func (sc *SystemdClient) Reload(ctx context.Context, unit string) (types.Job, error)
- func (sc *SystemdClient) Restart(ctx context.Context, unit string) (types.Job, error)
- func (sc *SystemdClient) Start(ctx context.Context, unit string) (types.Job, error)
- func (sc *SystemdClient) Stop(ctx context.Context, unit string) (types.Job, error)
- func (sc *SystemdClient) SystemJournal(ctx context.Context, lines int) ([]map[string]any, error)
- func (sc *SystemdClient) Unit(ctx context.Context, unit string) (map[string]any, error)
- func (sc *SystemdClient) UnitFile(ctx context.Context, unit string) (string, error)
- func (sc *SystemdClient) Units(ctx context.Context) ([]dbus.UnitStatus, error)
- type VarsClient
- func (vc *VarsClient) Config(ctx context.Context) (integrationsTypes.VarsConfig, error)
- func (vc *VarsClient) Delete(ctx context.Context, key string) error
- func (vc *VarsClient) Env(ctx context.Context) (string, error)
- func (vc *VarsClient) Get(ctx context.Context, key string) (string, error)
- func (vc *VarsClient) List(ctx context.Context) (map[string]string, error)
- func (vc *VarsClient) Set(ctx context.Context, key, value string) error
Constants ¶
This section is empty.
Variables ¶
var ( Peers map[key.NodePublic]*ipnstate.PeerStatus TTL = 15 * time.Minute )
Functions ¶
func AuthMiddleware ¶
AuthMiddleware authenticates every inbound request via Tailscale's WhoIs API.
func Discover ¶
Discover finds all online tailnet peers that have the named tool installed. An empty minVersion matches any version.
func DiscoverVersion ¶
func DiscoverVersion(ctx context.Context, srv *Server, toolName, minVersion string) ([]types.Peer, error)
DiscoverVersion is like Discover but requires at least minVersion.
func ExecWith ¶
ExecWith injects vars into the environment of a local subprocess and runs it. Vars are set as KEY=VALUE environment variables. The subprocess inherits the current process's environment with the vars overlaid on top.
Secrets exist only in the child process environment and disappear when it exits — they are never written to disk.
Example:
vars, err := tailkit.Node(srv, "vps-1").Vars("myapp", "prod").List(ctx)
err = tailkit.ExecWith(ctx, vars, []string{"/usr/bin/node", "server.js"})
func GetPeerTools ¶ added in v0.1.12
func GetPeers ¶ added in v0.1.12
func GetPeers(ctx context.Context, srv *Server) (map[key.NodePublic]*ipnstate.PeerStatus, error)
func GetTailkitHostname ¶ added in v0.2.2
func GetTailkitPeer ¶ added in v0.1.12
func Install ¶
Install writes a Tool registration file to /etc/tailkitd/tools/{name}.json.
Call Install once at install time and again on every tool upgrade. tailkitd reads this file to populate its tool registry and exec command list. The write is atomic — tailkitd will never read a partially-written file.
Install validates:
- Tool.Name is non-empty and matches [a-zA-Z0-9_-]+
- Tool.Version is non-empty
- Each Command.Name is non-empty
- Each Command.ExecParts is non-empty and ExecParts[0] exists on disk
- Each Command.Timeout is positive
- Each Arg.Pattern (if set) is a valid regular expression
It creates /etc/tailkitd/tools/ if it does not exist.
func OnlinePeers ¶ added in v0.1.12
OnlinePeers returns all online tailnet peers running tailkitd (hostname starts with "tailkitd-"), querying via the system Tailscale daemon.
func TailkitPeers ¶ added in v0.1.12
Types ¶
type CallerContextKey ¶
type CallerContextKey struct{}
CallerContextKey is the exported context key type for CallerIdentity.
type CallerIdentity ¶
type CallerIdentity struct {
Hostname string
TailscaleIP string
UserLogin string
Caps map[string]bool
}
CallerIdentity holds the verified identity of the caller on an inbound request.
func CallerFromContext ¶
func CallerFromContext(ctx context.Context) (CallerIdentity, bool)
CallerFromContext retrieves the CallerIdentity injected by AuthMiddleware.
func (CallerIdentity) HasCap ¶
func (id CallerIdentity) HasCap(cap string) bool
HasCap reports whether the caller was granted the given ACL capability.
type ComposeClient ¶
type ComposeClient struct {
// contains filtered or unexported fields
}
ComposeClient provides access to Docker Compose operations.
func (*ComposeClient) Project ¶
func (cc *ComposeClient) Project(ctx context.Context, name string) (types.ComposeService, error)
func (*ComposeClient) Projects ¶
func (cc *ComposeClient) Projects(ctx context.Context) ([]types.ComposeService, error)
type DockerClient ¶
type DockerClient struct {
// contains filtered or unexported fields
}
DockerClient provides typed access to the /integrations/docker endpoints.
func (*DockerClient) Available ¶
func (dc *DockerClient) Available(ctx context.Context) (bool, error)
Available returns false if Docker is not configured or the daemon is down. Never returns a Go error — callers can use it as a boolean check.
func (*DockerClient) Compose ¶
func (dc *DockerClient) Compose() *ComposeClient
func (*DockerClient) Config ¶ added in v0.3.0
func (dc *DockerClient) Config(ctx context.Context) (integrationsTypes.DockerConfig, error)
func (*DockerClient) Container ¶
func (dc *DockerClient) Container(ctx context.Context, id string) (container.InspectResponse, error)
func (*DockerClient) Containers ¶
func (*DockerClient) Swarm ¶
func (dc *DockerClient) Swarm() *SwarmClient
type FilesClient ¶
type FilesClient struct {
// contains filtered or unexported fields
}
FilesClient provides typed access to the /files endpoints on a node. Obtain via NodeClient.Files().
func (*FilesClient) Config ¶ added in v0.3.0
func (fc *FilesClient) Config(ctx context.Context) (integrationsTypes.FilesConfig, error)
func (*FilesClient) Download ¶
func (fc *FilesClient) Download(ctx context.Context, remotePath, localPath string) error
Download fetches a file from the node and writes it to localPath.
func (*FilesClient) Send ¶ added in v0.3.0
func (fc *FilesClient) Send(ctx context.Context, req types.SendRequest) (types.SendResult, error)
Send pushes a local file to the node. Returns a SendResult; if a post_recv hook was triggered, SendResult.JobID is set and can be polled with ExecJob.
func (*FilesClient) SendDir ¶ added in v0.3.0
func (fc *FilesClient) SendDir(ctx context.Context, req types.SendDirRequest) ([]types.SendResult, error)
SendDir pushes all files in a local directory to the node recursively. Returns one SendResult per file; errors are collected, not propagated.
type FleetClient ¶
type FleetClient struct {
// contains filtered or unexported fields
}
FleetClient fans out operations to all online tailkitd nodes. Obtain via tailkit.AllNodes(srv).
func Nodes ¶ added in v0.1.12
func Nodes(srv *Server, peers []types.Peer) *FleetClient
Nodes returns a FleetClient that fans out requests to the given peers. fans out requests to them with bounded parallelism (10 concurrent).
func (*FleetClient) Files ¶ added in v0.3.0
func (f *FleetClient) Files() *FleetFilesClient
func (*FleetClient) Metrics ¶
func (f *FleetClient) Metrics() *FleetMetricsClient
func (*FleetClient) Vars ¶
func (f *FleetClient) Vars(project, env string) *FleetVarsClient
type FleetFilesClient ¶ added in v0.3.0
type FleetFilesClient struct {
// contains filtered or unexported fields
}
FleetFilesClient fans out files requests to all nodes.
func (*FleetFilesClient) Config ¶ added in v0.3.0
func (ff *FleetFilesClient) Config(ctx context.Context) (map[string]integrationsTypes.FilesConfig, map[string]error)
func (*FleetFilesClient) Send ¶ added in v0.3.0
func (ff *FleetFilesClient) Send(ctx context.Context, req types.SendRequest) (map[string]types.SendResult, map[string]error)
func (*FleetFilesClient) SendDir ¶ added in v0.3.0
func (ff *FleetFilesClient) SendDir(ctx context.Context, req types.SendDirRequest) (map[string][]types.SendResult, map[string]error)
type FleetMetricsClient ¶
type FleetMetricsClient struct {
// contains filtered or unexported fields
}
FleetMetricsClient fans out metrics requests to all nodes.
func (*FleetMetricsClient) Config ¶ added in v0.3.0
func (fm *FleetMetricsClient) Config(ctx context.Context) (map[string]integrationsTypes.MetricsConfig, map[string]error)
type FleetVarsClient ¶
type FleetVarsClient struct {
// contains filtered or unexported fields
}
FleetVarsClient fans out var operations across all nodes.
func (*FleetVarsClient) Config ¶ added in v0.3.0
func (fv *FleetVarsClient) Config(ctx context.Context) (map[string]integrationsTypes.VarsConfig, map[string]error)
func (*FleetVarsClient) List ¶
func (fv *FleetVarsClient) List(ctx context.Context) (map[string]map[string]string, map[string]error)
List reads the scope from every node. Nodes where the scope is not configured return ErrVarScopeNotFound in the error map.
type MetricsClient ¶
type MetricsClient struct {
// contains filtered or unexported fields
}
MetricsClient provides typed access to the /integrations/metrics endpoints.
func (*MetricsClient) Available ¶
func (mc *MetricsClient) Available(ctx context.Context) (bool, error)
func (*MetricsClient) Config ¶ added in v0.3.0
func (mc *MetricsClient) Config(ctx context.Context) (integrationsTypes.MetricsConfig, error)
type NodeClient ¶
type NodeClient struct {
// contains filtered or unexported fields
}
NodeClient is the entry point for all operations on a single tailkitd node. Obtain one via tailkit.Node(srv, "hostname").
func Node ¶
func Node(srv *Server, hostname string) *NodeClient
Node returns a NodeClient that communicates with the tailkitd instance running on the named node. The hostname is the node's Tailscale hostname (e.g. "warehouse-13-1") — tailkit prepends "tailkitd-" to form the tsnet hostname "tailkitd-warehouse-13-1.<tailnet>.ts.net".
Node construction is free — no network calls are made until a method is called on the returned client or one of its sub-clients.
func (*NodeClient) Docker ¶
func (n *NodeClient) Docker() *DockerClient
func (*NodeClient) ExecWait ¶
ExecWait fires a command and blocks until it completes or ctx is cancelled. Cancelling ctx stops polling but does not cancel the running job on the node.
func (*NodeClient) Files ¶
func (n *NodeClient) Files() *FilesClient
Files returns a FilesClient for this node.
func (*NodeClient) HasTool ¶
HasTool reports whether the node has a specific tool installed at or above the given minimum version. An empty minVersion matches any version.
func (*NodeClient) Metrics ¶
func (n *NodeClient) Metrics() *MetricsClient
func (*NodeClient) Systemd ¶
func (n *NodeClient) Systemd() *SystemdClient
func (*NodeClient) Vars ¶
func (n *NodeClient) Vars(project, env string) *VarsClient
Vars returns a VarsClient scoped to project/env.
type Server ¶
Server is a tailkit-managed tsnet server.
func NewServer ¶
func NewServer(cfg ServerConfig) (*Server, error)
NewServer constructs and starts a tsnet server.
func (*Server) ListenAndServe ¶
ListenAndServe starts a plain HTTP server on the tsnet listener.
func (*Server) ListenAndServeTLS ¶
ListenAndServeTLS starts an HTTPS server on the tsnet listener.
type ServerConfig ¶
ServerConfig holds configuration for a tailkit-managed tsnet server.
type SwarmClient ¶
type SwarmClient struct {
// contains filtered or unexported fields
}
SwarmClient provides access to Docker Swarm read operations.
type SystemdClient ¶
type SystemdClient struct {
// contains filtered or unexported fields
}
SystemdClient provides typed access to the /integrations/systemd endpoints.
func (*SystemdClient) Available ¶
func (sc *SystemdClient) Available(ctx context.Context) (bool, error)
func (*SystemdClient) Config ¶ added in v0.3.0
func (sc *SystemdClient) Config(ctx context.Context) (integrationsTypes.SystemdConfig, error)
func (*SystemdClient) SystemJournal ¶
func (*SystemdClient) Units ¶
func (sc *SystemdClient) Units(ctx context.Context) ([]dbus.UnitStatus, error)
type VarsClient ¶
type VarsClient struct {
// contains filtered or unexported fields
}
VarsClient provides typed access to the /vars endpoints on a node.
func (*VarsClient) Config ¶ added in v0.3.0
func (vc *VarsClient) Config(ctx context.Context) (integrationsTypes.VarsConfig, error)
func (*VarsClient) Delete ¶
func (vc *VarsClient) Delete(ctx context.Context, key string) error
Delete removes a var from the scope.
func (*VarsClient) Env ¶
func (vc *VarsClient) Env(ctx context.Context) (string, error)
Env returns all vars rendered as sorted KEY=VALUE lines suitable for sourcing in a shell script or writing to a .env file.