client

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventError = "error"

	EventJobStdout    = "job.stdout"
	EventJobStderr    = "job.stderr"
	EventJobStatus    = "job.status"
	EventJobCompleted = "job.completed"
	EventJobFailed    = "job.failed"

	EventDockerContainer = "docker.container"
	EventDockerAll       = "docker.all"

	EventLogLine       = "log.line"
	EventStatsSnapshot = "stats.snapshot"

	EventJournalEntry = "journal.entry"

	EventCPU       = "metrics.cpu"
	EventMemory    = "metrics.memory"
	EventNetwork   = "metrics.network"
	EventProcesses = "metrics.processes"
	EventAll       = "metrics.all"

	EventPortsSnapshot = "ports.snapshot"
	EventPortBound     = "port.bound"
	EventPortReleased  = "port.released"
)
View Source
const (
	// PatternIdentifier matches container names, service names, etc.
	PatternIdentifier = `^[a-zA-Z0-9_-]+$`
	// PatternPath matches absolute unix paths.
	PatternPath = `^(/[a-zA-Z0-9_./-]+)+$`
	// PatternSemver matches semantic version strings.
	PatternSemver = `^v?[0-9]+\.[0-9]+\.[0-9]+$`
	// PatternIP matches IPv4 addresses.
	PatternIP = `^(\d{1,3}\.){3}\d{1,3}$`
	// PatternPort matches valid port numbers.
	PatternPort = `^([1-9][0-9]{0,4})$`
	// PatternFilename matches safe filenames.
	PatternFilename = `^[a-zA-Z0-9_.,-]+$`
)

Variables

View Source
var (
	ErrReceiveNotConfigured = errors.New("tailkit: node has no files.toml (receive not configured)")
	ErrToolNotFound         = errors.New("tailkit: tool not installed on node")
	ErrCommandNotFound      = errors.New("tailkit: command not registered by tool")
	ErrDockerUnavailable    = errors.New("tailkit: node has no docker.toml or daemon not running")
	ErrSystemdUnavailable   = errors.New("tailkit: node has no systemd.toml or D-Bus unavailable")
	ErrMetricsUnavailable   = errors.New("tailkit: node has no metrics.toml")
	ErrVarScopeNotFound     = errors.New("tailkit: project/env scope not in vars.toml")
	ErrPermissionDenied     = errors.New("tailkit: ACL cap or node config blocked the operation")
	ErrUnauthorized         = errors.New("tailkit: unauthorized")
	ErrConflict             = errors.New("tailkit: conflict")
)

Functions

func FanOut

func FanOut[T any](ctx context.Context, hostnames []string, fn func(context.Context, string) (T, error)) (map[string]T, map[string]error)

func StreamEvents

func StreamEvents[T any](ctx context.Context, body io.ReadCloser, allowedEvents []string, fn func(Event[T]) error) error

StreamEvents reads SSE from the body and unmarshals them into the requested type T.

Types

type AgentListOptions

type AgentListOptions struct {
	Online bool
}

type AgentScope

type AgentScope struct {
	Backend  ClientBackend
	Hostname string
}

func (AgentScope) Events

func (a AgentScope) Events() EventsScope

func (AgentScope) Execute

func (a AgentScope) Execute(ctx context.Context, cmd string, args []string) ([]byte, error)

func (AgentScope) Get

func (a AgentScope) Get(ctx context.Context) (Tailkitd, error)

func (AgentScope) Logs

func (a AgentScope) Logs() LogsScope

func (AgentScope) Restart

func (a AgentScope) Restart(ctx context.Context) error

func (AgentScope) Services

func (a AgentScope) Services() AgentServicesScope

func (AgentScope) Update

func (a AgentScope) Update(ctx context.Context, version string) error

type AgentServicesScope

type AgentServicesScope struct {
	Backend  ClientBackend
	Hostname string
}

AgentServicesScope is the concrete struct for an agent's local workloads.

func (AgentServicesScope) List

type AgentsScope

type AgentsScope struct {
	Backend   ClientBackend
	Hostnames []string
}

func (AgentsScope) List

func (h AgentsScope) List(ctx context.Context, opts ...AgentListOptions) (map[string]Tailkitd, map[string]error)

type Arg

type Arg struct {
	// Name is the template variable name used in ExecParts (e.g. "container").
	Name string `json:"name"`
	// Type is the value type: "string", "int", "bool".
	Type string `json:"type"`
	// Required indicates the arg must be supplied by the caller.
	Required bool `json:"required"`
	// Pattern is a regex the value must match before substitution.
	// Use the PatternXxx constants or a custom expression.
	Pattern string `json:"pattern,omitempty"`
}

Arg describes a single parameter accepted by a Command.

type CPU

type CPU struct {
	Info    []gopsutilcpu.InfoStat `json:"info"`
	Percent []float64              `json:"percent_per_cpu"`
	Total   float64                `json:"percent_total"`
}

CPU bundles per-CPU usage percentages with static CPU info.

type ClientBackend

type ClientBackend interface {
	// Do executes an HTTP request against a specific node and decodes JSON into 'out'
	Do(ctx context.Context, hostname, method, path string, body io.Reader, out any) error

	// DoRaw executes a request and returns the raw bytes (useful for files/logs)
	DoRaw(ctx context.Context, hostname, method, path string, body io.Reader, accept string) ([]byte, error)

	// Stream opens an SSE or continuous log stream
	Stream(ctx context.Context, hostname, method, path string) (io.ReadCloser, error)

	Peers(ctx context.Context, opts *PeerListOptions) ([]string, error)

	Hosts(ctx context.Context, opts *HostListOptions) ([]string, error)

	Agents(ctx context.Context, opts *AgentListOptions) ([]string, error)
}

ClientBackend defines the underlying network transport layer. All concrete scopes will hold a pointer to this to execute requests.

type ComposeScope

type ComposeScope struct {
	Backend  ClientBackend
	Hostname string
}

Compose

func (ComposeScope) Service added in v0.5.2

func (c ComposeScope) Service(name string) ComposeServicescope

func (ComposeScope) Services added in v0.5.2

func (c ComposeScope) Services(ctx context.Context) ([]ComposeService, error)

type ComposeService

type ComposeService struct {
	Name        string   `json:"name"`
	Status      string   `json:"status"`
	ConfigFiles []string `json:"config_files"`
}

type ComposeServicescope added in v0.5.2

type ComposeServicescope struct {
	Backend     ClientBackend
	Hostname    string
	ServiceName string
}

func (ComposeServicescope) Build added in v0.5.2

func (c ComposeServicescope) Build(ctx context.Context) (Job, error)

func (ComposeServicescope) Down added in v0.5.2

func (c ComposeServicescope) Down(ctx context.Context) (Job, error)

func (ComposeServicescope) Get added in v0.5.2

func (ComposeServicescope) Pull added in v0.5.2

func (c ComposeServicescope) Pull(ctx context.Context) (Job, error)

func (ComposeServicescope) Restart added in v0.5.2

func (c ComposeServicescope) Restart(ctx context.Context) (Job, error)

func (ComposeServicescope) Up added in v0.5.2

func (c ComposeServicescope) Up(ctx context.Context, composeFile string) (Job, error)

type Container

type Container = container.Summary

Container aliases the Docker SDK container summary.

type ContainerScope

type ContainerScope struct {
	Backend     ClientBackend
	Hostname    string
	ContainerID string
}

Container Actions

func (ContainerScope) Inspect

func (ContainerScope) Logs

func (c ContainerScope) Logs(ctx context.Context, tailLines int) (io.ReadCloser, error)

func (ContainerScope) Remove

func (c ContainerScope) Remove(ctx context.Context) error

func (ContainerScope) Restart

func (c ContainerScope) Restart(ctx context.Context) error

func (ContainerScope) Start

func (c ContainerScope) Start(ctx context.Context) error

func (ContainerScope) Stop

func (c ContainerScope) Stop(ctx context.Context) error

func (ContainerScope) Stream added in v0.5.2

func (d ContainerScope) Stream(ctx context.Context, fn func(Event[DockerEvent]) error) error

func (ContainerScope) StreamLogs

func (c ContainerScope) StreamLogs(ctx context.Context, tail int, fn func(Event[LogLine]) error) error

Stream logs for a specific container

func (ContainerScope) StreamStats

func (c ContainerScope) StreamStats(ctx context.Context, fn func(Event[container.StatsResponse]) error) error

Stream stats for a specific container

type ContainersNamespace

type ContainersNamespace struct {
	Backend  ClientBackend
	Hostname string
}

Containers

func (ContainersNamespace) List

type DirEntry

type DirEntry struct {
	Name    string    `json:"name"`
	Size    int64     `json:"size"`
	IsDir   bool      `json:"is_dir"`
	ModTime time.Time `json:"mod_time"`
	Mode    string    `json:"mode"`
}

DirEntry is a single entry in a directory listing.

type DirScope

type DirScope struct {
	Backend  ClientBackend
	Hostname string
	Path     string
}

func (DirScope) List

func (d DirScope) List(ctx context.Context) ([]DirEntry, error)

func (DirScope) Send

func (d DirScope) Send(ctx context.Context, req SendDirRequest) ([]SendResult, error)

type Disk

type Disk = *gopsutildisk.UsageStat

type DockerEvent

type DockerEvent = events.Message

type DockerScope

type DockerScope struct {
	Backend  ClientBackend
	Hostname string
}

========================================== Integration Scopes (Concrete) ==========================================

func (DockerScope) Compose

func (d DockerScope) Compose() ComposeScope

func (DockerScope) Config added in v0.5.2

func (DockerScope) Container

func (d DockerScope) Container(id string) ContainerScope

func (DockerScope) Containers

func (d DockerScope) Containers() ContainersNamespace

func (DockerScope) Images

func (d DockerScope) Images() ImagesNamespace

func (DockerScope) Stream

func (d DockerScope) Stream(ctx context.Context, fn func(Event[DockerEvent]) error) error

func (DockerScope) Swarm

func (d DockerScope) Swarm() SwarmScope

type Event

type Event[T any] struct {
	Name string `json:"name"`
	ID   int64  `json:"id"`
	Data T      `json:"data"`
}

Event is one typed server-sent event received from a tailkitd stream.

func DecodeEvent

func DecodeEvent[T any](raw RawEvent) (Event[T], error)

type EventsScope

type EventsScope struct {
	Backend  ClientBackend
	Hostname string
}

func (EventsScope) Stream

func (e EventsScope) Stream(ctx context.Context) (io.ReadCloser, error)

type FileScope

type FileScope struct {
	Backend  ClientBackend
	Hostname string
	Path     string
}

func (FileScope) Config

func (FileScope) Delete

func (f FileScope) Delete(ctx context.Context) error

func (FileScope) Download

func (f FileScope) Download(ctx context.Context, localDestPath string) error

func (FileScope) Read

func (f FileScope) Read(ctx context.Context) (io.ReadCloser, error)

func (FileScope) Send

func (f FileScope) Send(ctx context.Context, req SendRequest) (SendResult, error)

func (FileScope) Stat

func (f FileScope) Stat(ctx context.Context) (FileStat, error)

func (FileScope) Write

func (f FileScope) Write(ctx context.Context, content io.Reader) error

type FileStat

type FileStat struct {
	DirEntry
	SHA256 string `json:"sha256"`
}

type FilesScope

type FilesScope struct {
	Backend  ClientBackend
	Hostname string
}

Files

func (FilesScope) Dir

func (f FilesScope) Dir(path string) DirScope

func (FilesScope) File

func (f FilesScope) File(path string) FileScope

type FleetFilesScope

type FleetFilesScope struct {
	Backend   ClientBackend
	Hostnames []string
}

func (FleetFilesScope) Config

func (FleetFilesScope) List

func (ff FleetFilesScope) List(ctx context.Context, path string) (map[string][]DirEntry, map[string]error)

func (FleetFilesScope) Send

func (ff FleetFilesScope) Send(ctx context.Context, req SendRequest) (map[string]SendResult, map[string]error)

func (FleetFilesScope) Stat

func (ff FleetFilesScope) Stat(ctx context.Context, path string) (map[string]FileStat, map[string]error)

type FleetMetricsScope

type FleetMetricsScope struct {
	Backend   ClientBackend
	Hostnames []string
}

func (FleetMetricsScope) All

func (fm FleetMetricsScope) All(ctx context.Context) (map[string]Metrics, map[string]error)

func (FleetMetricsScope) CPU

func (fm FleetMetricsScope) CPU(ctx context.Context) (map[string]CPU, map[string]error)

func (FleetMetricsScope) Config

func (FleetMetricsScope) Memory

func (fm FleetMetricsScope) Memory(ctx context.Context) (map[string]Memory, map[string]error)

type FleetVarsScope

type FleetVarsScope struct {
	Backend   ClientBackend
	Hostnames []string
	Service   string
	Env       string
}

func (FleetVarsScope) Config

func (FleetVarsScope) List

func (fv FleetVarsScope) List(ctx context.Context) (map[string]map[string]string, map[string]error)

func (FleetVarsScope) Set

func (fv FleetVarsScope) Set(ctx context.Context, key, value string) map[string]error

type Host

type Host struct {
	Name         string            `json:"name"`
	Role         string            `json:"role"`
	Environment  string            `json:"environment"`
	Provider     string            `json:"provider"`
	InstanceType string            `json:"instance_type"`
	Tags         []string          `json:"tags"`
	Metadata     map[string]string `json:"metadata"`

	Peer     *Peer     `json:"peer,omitempty"`
	Tailkitd *Tailkitd `json:"tailkitd,omitempty"`

	TSHostname string   `json:"ts_hostname"`
	TSDNSName  string   `json:"ts_dns_name"`
	TSIPs      []string `json:"ts_ips"`
	OS         string   `json:"os"`
	Arch       string   `json:"arch"`
	Online     bool     `json:"online"`
	IsAdmin    bool     `json:"is_admin"`
}

Host is a tailnet peer that has an associated tailkitd sidecar.

func (*Host) IsClassified

func (h *Host) IsClassified() bool

IsClassified reports whether an admin has assigned a non-default role.

type HostListOptions

type HostListOptions struct {
	Online      bool
	Tags        []string
	Environment string
}

type HostScope

type HostScope struct {
	Backend  ClientBackend
	Hostname string
}

func (HostScope) Agent

func (h HostScope) Agent() AgentScope

func (HostScope) Docker

func (h HostScope) Docker() DockerScope

func (HostScope) Files

func (h HostScope) Files() FilesScope

func (HostScope) Get

func (h HostScope) Get(ctx context.Context) (Host, error)

func (HostScope) Metrics

func (h HostScope) Metrics() MetricsScope

func (HostScope) Systemd

func (h HostScope) Systemd() SystemdScope

func (HostScope) Vars

func (h HostScope) Vars(Service, env string) VarsScope

type HostsScope

type HostsScope struct {
	Backend   ClientBackend
	Hostnames []string
}

func (HostsScope) Files

func (h HostsScope) Files() FleetFilesScope

func (HostsScope) List

func (h HostsScope) List(ctx context.Context, opts ...HostListOptions) (map[string]Host, map[string]error)

func (HostsScope) Metrics

func (h HostsScope) Metrics() FleetMetricsScope

func (HostsScope) Vars

func (h HostsScope) Vars(Service, env string) FleetVarsScope

type Image

type Image = image.Summary

Image aliases the Docker SDK image summary.

type ImagesNamespace

type ImagesNamespace struct {
	Backend  ClientBackend
	Hostname string
}

Images

func (ImagesNamespace) List

func (i ImagesNamespace) List(ctx context.Context) ([]Image, error)

func (ImagesNamespace) Pull

func (i ImagesNamespace) Pull(ctx context.Context, ref string) (Image, error)

func (ImagesNamespace) Push

func (i ImagesNamespace) Push(ctx context.Context, ref string) (Image, error)

type Job

type Job struct {
	// JobID is the opaque identifier used to poll for results.
	JobID  string    `json:"job_id"`
	Status JobStatus `json:"status"`
}

Job is the immediate response from a fire-and-forget exec invocation.

type JobResult

type JobResult struct {
	JobID      string    `json:"job_id"`
	Status     JobStatus `json:"status"`
	ExitCode   int       `json:"exit_code"`
	Stdout     string    `json:"stdout"`
	Stderr     string    `json:"stderr"`
	DurationMs int64     `json:"duration_ms"`
	// Error is set when the job failed to start (not when the command exits non-zero).
	Error string `json:"error,omitempty"`
}

JobResult is returned when polling a completed job.

type JobStatus

type JobStatus string

JobStatus represents the lifecycle state of an async job.

const (
	JobStatusAccepted  JobStatus = "accepted"
	JobStatusRunning   JobStatus = "running"
	JobStatusCompleted JobStatus = "completed"
	JobStatusFailed    JobStatus = "failed"
	JobStatusCancelled JobStatus = "cancelled"
)

type JobUpdate

type JobUpdate struct {
	Event    string    `json:"-"`
	JobID    string    `json:"job_id"`
	Line     string    `json:"line,omitempty"`
	Stream   string    `json:"stream,omitempty"`
	Status   JobStatus `json:"status,omitempty"`
	ExitCode int       `json:"exit_code,omitempty"`
	Error    string    `json:"error,omitempty"`
}

JobUpdate is the typed payload emitted by exec job streams. Event identifies the originating SSE event name.

type JournalEntry

type JournalEntry struct {
	Timestamp uint64            `json:"timestamp_us"` // realtime timestamp in microseconds
	Message   string            `json:"message"`
	Unit      string            `json:"unit,omitempty"`
	Priority  string            `json:"priority,omitempty"`
	Fields    map[string]string `json:"fields,omitempty"`
}

JournalEntry is one systemd journal entry.

type LogLine

type LogLine struct {
	ContainerID string    `json:"container_id"`
	Stream      string    `json:"stream"`
	TS          time.Time `json:"ts"`
	Line        string    `json:"line"`
}

LogLine is emitted by Docker log streams.

type LogsScope

type LogsScope struct {
	Backend  ClientBackend
	Hostname string
}

Sub-Scopes

func (LogsScope) Stream

func (l LogsScope) Stream(ctx context.Context) (io.ReadCloser, error)

type Memory

type Memory struct {
	Virtual *gopsutilmem.VirtualMemoryStat `json:"virtual"`
	Swap    *gopsutilmem.SwapMemoryStat    `json:"swap"`
}

type Metrics

type Metrics struct {
	Host      *gopsutilhost.InfoStat       `json:"host,omitempty"`
	CPU       *CPU                         `json:"cpu,omitempty"`
	Memory    *Memory                      `json:"memory,omitempty"`
	Disk      []*gopsutildisk.UsageStat    `json:"disk,omitempty"`
	Network   []gopsutilnet.IOCountersStat `json:"network,omitempty"`
	Processes []Process                    `json:"processes,omitempty"`
	Ports     []Port                       `json:"ports,omitempty"`

} // metrics/handler328

Metrics is the typed payload emitted by the metrics all stream.

type MetricsScope

type MetricsScope struct {
	Backend  ClientBackend
	Hostname string
}

Metrics

func (MetricsScope) All added in v0.5.2

func (m MetricsScope) All(ctx context.Context, fn func(Event[Metrics]) error) error

func (MetricsScope) CPU

func (m MetricsScope) CPU(ctx context.Context) (CPU, error)

func (MetricsScope) Disk

func (m MetricsScope) Disk(ctx context.Context) ([]Disk, error)

func (MetricsScope) Memory

func (m MetricsScope) Memory(ctx context.Context) (Memory, error)

func (MetricsScope) Network

func (m MetricsScope) Network(ctx context.Context) ([]Network, error)

func (MetricsScope) Ports added in v0.5.2

func (m MetricsScope) Ports(ctx context.Context) ([]Port, error)

func (MetricsScope) Processes

func (m MetricsScope) Processes(ctx context.Context) ([]Process, error)

func (MetricsScope) Stream added in v0.5.2

func (m MetricsScope) Stream() MetricsStreamScope

type MetricsStreamScope added in v0.5.2

type MetricsStreamScope struct {
	Backend  ClientBackend
	Hostname string
}

func (MetricsStreamScope) CPU added in v0.5.2

func (m MetricsStreamScope) CPU(ctx context.Context, fn func(Event[CPU]) error) error

func (MetricsStreamScope) Memory added in v0.5.2

func (m MetricsStreamScope) Memory(ctx context.Context, fn func(Event[Memory]) error) error

func (MetricsStreamScope) Ports added in v0.5.2

func (m MetricsStreamScope) Ports(ctx context.Context, fn func(Event[PortUpdate]) error) error

type Network

type Network = gopsutilnet.IOCountersStat

type Peer

type Peer struct {
	ID        string            `json:"id,omitempty"`
	PublicKey string            `json:"public_key,omitempty"`
	HostName  string            `json:"host_name,omitempty"`
	DNSName   string            `json:"dns_name,omitempty"`
	IPs       []string          `json:"ips"`
	OS        string            `json:"os,omitempty"`
	Online    bool              `json:"online"`
	Metadata  map[string]string `json:"metadata,omitempty"`

	// Status keeps the raw Tailscale peer payload available for local SDK
	// enrichment and classification without making it part of the shared wire
	// contract.
	Status *ipnstate.PeerStatus `json:"-"`
}

Peer is a tailnet machine identity as reported by Tailscale.

type PeerListOptions

type PeerListOptions struct{ Online bool }

type PeerScope

type PeerScope struct {
	Backend  ClientBackend
	Hostname string
}

func (PeerScope) Get

func (p PeerScope) Get(ctx context.Context) (*Peer, error)

func (PeerScope) Host

func (p PeerScope) Host() HostScope

type PeersScope

type PeersScope struct {
	Backend   ClientBackend
	Hostnames []string
}

func (PeersScope) List

func (h PeersScope) List(ctx context.Context, opt PeerListOptions) (map[string]Peer, map[string]error)

type Port

type Port struct {
	Addr    string `json:"addr"`
	Port    uint16 `json:"port"`
	Proto   string `json:"proto"`
	PID     int    `json:"pid"`
	Process string `json:"process"`
}

type PortUpdate

type PortUpdate struct {
	Kind  string `json:"kind"`
	Port  Port   `json:"port,omitempty"`
	Ports []Port `json:"ports,omitempty"`
}

PortUpdate is the typed payload emitted by the metrics ports stream. Snapshot events populate Ports; delta events populate Port.

type Process

type Process struct {
	PID        int32   `json:"pid"`
	Name       string  `json:"name"`
	Status     string  `json:"status"`
	CPUPercent float64 `json:"cpu_percent"`
	MemoryRSS  uint64  `json:"memory_rss_bytes"`
	Cmdline    string  `json:"cmdline"`
}

type RawEvent

type RawEvent struct {
	Name string
	ID   int64
	Data json.RawMessage
}

RawEvent is the parser-side SSE envelope used before typed decoding.

type SendDirRequest

type SendDirRequest struct {
	// ToolName is the name of the tool that sent the directory.
	ToolName string `json:"tool_name"`
	// Filename is the name of the file that was sent.
	Filename string `json:"filename"`
	// LocalDir is the absolute path to the source directory on the caller's machine.
	LocalDir string
	// DestPath is the absolute destination directory path on the node.
	DestPath string
}

SendDirRequest describes a directory tree to push to a remote node.

type SendRequest

type SendRequest struct {
	// ToolName is the name of the tool that sent the file.
	ToolName string `json:"tool_name"`
	// Filename is the name of the file that was sent.
	Filename string `json:"filename"`
	// LocalPath is the absolute path to the file on the caller's machine.
	LocalPath string
	// DestPath is the absolute path the file should be written to on the node.
	DestPath string
}

SendRequest describes a single file to push to a remote node.

type SendResult

type SendResult struct {
	// ToolName is the name of the tool that sent the file.
	ToolName string `json:"tool_name"`

	// Filename is the name of the file that was sent.
	Filename string `json:"filename"`

	LocalPath string `json:"local_path"`
	// Success indicates whether the file was successfully sent.
	Success bool `json:"success"`
	// WrittenTo is the absolute path the file was written to on the node.
	WrittenTo string `json:"written_to"`
	// BytesWritten is the number of bytes written.
	BytesWritten int64 `json:"bytes_written"`
	// DestMachine is the hostname of the machine the file was sent to.
	DestMachine string `json:"dest_machine"`
	//Error is set when the file was not successfully sent.
	Error string `json:"error,omitempty"`
}

SendResult is the response from a Send or SendDir operation.

type Service

type Service struct {
	ID          string `json:"id,omitempty"`
	Name        string `json:"name"`
	Kind        string `json:"kind,omitempty"`
	Runtime     string `json:"runtime"`
	HostName    string `json:"host_name,omitempty"`
	NodeName    string `json:"node_name,omitempty"`
	Description string `json:"description,omitempty"`

	Source        string   `json:"source,omitempty"`
	Priority      string   `json:"priority,omitempty"`
	Tags          []string `json:"tags"`
	Version       string   `json:"version,omitempty"`
	Addresses     []string `json:"addresses"`
	Ports         []uint16 `json:"ports"`
	ExpectedPorts []uint16 `json:"expected_ports,omitempty"`

	SystemdUnit string `json:"systemd_unit,omitempty"`
	ContainerID string `json:"container_id,omitempty"`
	BinaryPath  string `json:"binary_path,omitempty"`
	PidFile     string `json:"pid_file,omitempty"`

	Capabilities ServiceCapabilities `json:"capabilities"`
	Status       ServiceStatus       `json:"status"`
}

Service represents a workload declared on a tailkitd node.

func (*Service) Normalize

func (s *Service) Normalize()

Normalize fills nil collections and backwards-compatible host fields.

type ServiceCapabilities

type ServiceCapabilities struct {
	Status  bool `json:"status"`
	Start   bool `json:"start"`
	Stop    bool `json:"stop"`
	Restart bool `json:"restart"`
	Reload  bool `json:"reload"`
	Logs    bool `json:"logs"`
}

ServiceCapabilities describes which portable service operations are exposed.

type ServiceListOptions

type ServiceListOptions struct {
	Kind    string
	Runtime string
}

type ServiceScope

type ServiceScope struct {
	Backend   ClientBackend
	ServiceID string
}

func (ServiceScope) Get

func (s ServiceScope) Get(ctx context.Context) (Service, error)

func (ServiceScope) Host

func (s ServiceScope) Host() HostScope

func (ServiceScope) Logs

func (s ServiceScope) Logs(ctx context.Context, tailLines int) (io.ReadCloser, error)

func (ServiceScope) Reload

func (s ServiceScope) Reload(ctx context.Context) error

func (ServiceScope) Restart

func (s ServiceScope) Restart(ctx context.Context) error

func (ServiceScope) Start

func (s ServiceScope) Start(ctx context.Context) error

func (ServiceScope) Stop

func (s ServiceScope) Stop(ctx context.Context) error

type ServiceStatus

type ServiceStatus struct {
	State     string     `json:"state,omitempty"`
	Health    string     `json:"health,omitempty"`
	Message   string     `json:"message,omitempty"`
	PID       int        `json:"pid,omitempty"`
	StartedAt *time.Time `json:"started_at,omitempty"`
	UpdatedAt *time.Time `json:"updated_at,omitempty"`
}

ServiceStatus is the current runtime state of a service-like workload.

type ServicesScope

type ServicesScope struct {
	Backend   ClientBackend
	TargetIDs []string
}

func (ServicesScope) List

func (s ServicesScope) List(ctx context.Context, opts ...AgentListOptions) (map[string][]Service, map[string]error)

func (ServicesScope) Ports added in v0.5.2

func (s ServicesScope) Ports(ctx context.Context) ([]Port, error)

type SwarmScope

type SwarmScope struct {
	Backend  ClientBackend
	Hostname string
}

Swarm

func (SwarmScope) Join

func (s SwarmScope) Join(ctx context.Context, tokens []string) error

func (SwarmScope) Leave

func (s SwarmScope) Leave(ctx context.Context) error

func (SwarmScope) Services added in v0.5.2

func (s SwarmScope) Services() SwarmServicesNamespace

func (SwarmScope) Status

func (s SwarmScope) Status(ctx context.Context) (SwarmStatus, error)

func (SwarmScope) Stream added in v0.5.2

func (s SwarmScope) Stream() SwarmStreamScope

type SwarmServicesNamespace added in v0.5.2

type SwarmServicesNamespace struct {
	Backend  ClientBackend
	Hostname string
}

func (SwarmServicesNamespace) List added in v0.5.2

type SwarmStatus

type SwarmStatus = swarm.Swarm

SwarmStatus aliases the Docker SDK swarm info.

type SwarmStreamScope added in v0.5.2

type SwarmStreamScope struct {
	ID       string
	Backend  ClientBackend
	Hostname string
}

type SwarmUpdate added in v0.5.2

type SwarmUpdate struct {
	SwarmID []string
	Servies []swarm.Service
}

type SwarwService added in v0.5.2

type SwarwService = swarm.Service

type SystemdScope

type SystemdScope struct {
	Backend  ClientBackend
	Hostname string
}

Systemd

func (SystemdScope) Stream added in v0.5.2

func (s SystemdScope) Stream() SystemdStreamScope

func (SystemdScope) SystemJournal

func (s SystemdScope) SystemJournal(ctx context.Context, lines int) ([]JournalEntry, error)

func (SystemdScope) Unit

func (s SystemdScope) Unit(name string) UnitScope

func (SystemdScope) Units

func (s SystemdScope) Units() UnitsNamespace

type SystemdStreamScope added in v0.5.2

type SystemdStreamScope struct {
	Backend  ClientBackend
	Hostname string
}

func (SystemdStreamScope) System added in v0.5.2

func (s SystemdStreamScope) System(ctx context.Context, lines int, fn func(Event[JournalEntry]) error) error

type SystemdUnit

type SystemdUnit = dbus.UnitStatus

SystemdUnit aliases the CoreOS D-Bus unit status.

type Tailkitd

type Tailkitd struct {
	HostName string    `json:"host_name,omitempty"`
	Peer     *Peer     `json:"peer,omitempty"`
	Services []Service `json:"services"`
}

Tailkitd is a tailkitd-* tsnet sidecar peer that manages one host.

type TailnetClient

type TailnetClient interface {
	// Plural Namespaces (Optional variadic targets for fleet fan-outs)
	Peers(hostnames ...string) PeersScope
	Hosts(hostnames ...string) HostsScope
	Agents(hostnames ...string) AgentsScope
	Services(serviceIDs ...string) ServicesScope

	// Singular Namespaces
	Peer(hostname string) PeerScope
	Host(hostname string) HostScope
	Agent(hostname string) AgentScope
	Service(serviceID string) ServiceScope
}

========================================== Top-Level Tailnet Client (Mockable) ==========================================

type Tool

type Tool struct {
	// Name is a unique identifier for the tool across the tailnet.
	Name string `json:"name"`
	// Version is the tool's current version string (semver recommended).
	Version string `json:"version"`
	// TsnetHost is the tsnet hostname this tool registers on the tailnet.
	TsnetHost string `json:"tsnet_host"`
}

Tool is the registration record written to /etc/tailkitd/tools/{name}.json by tailkit.Install and read by tailkitd to populate its tool registry.

type UnitScope

type UnitScope struct {
	Backend  ClientBackend
	Hostname string
	UnitName string
}

func (UnitScope) Disable

func (u UnitScope) Disable(ctx context.Context) error

func (UnitScope) Enable

func (u UnitScope) Enable(ctx context.Context) error

func (UnitScope) File

func (u UnitScope) File(ctx context.Context) (string, error)

func (UnitScope) Get

func (u UnitScope) Get(ctx context.Context) (map[string]any, error)

func (UnitScope) Journal

func (u UnitScope) Journal(ctx context.Context, lines int) ([]JournalEntry, error)

func (UnitScope) Reload

func (u UnitScope) Reload(ctx context.Context) error

func (UnitScope) Restart

func (u UnitScope) Restart(ctx context.Context) error

func (UnitScope) Start

func (u UnitScope) Start(ctx context.Context) error

func (UnitScope) Status

func (u UnitScope) Status(ctx context.Context) (SystemdUnit, error)

func (UnitScope) Stop

func (u UnitScope) Stop(ctx context.Context) error

func (UnitScope) Stream added in v0.5.2

func (u UnitScope) Stream() UnitStreamScope

type UnitStreamScope added in v0.5.2

type UnitStreamScope struct {
	Backend  ClientBackend
	Hostname string
	UnitName string
}

func (UnitStreamScope) Journal added in v0.5.2

func (u UnitStreamScope) Journal(ctx context.Context, lines int, fn func(Event[JournalEntry]) error) error

type UnitsNamespace

type UnitsNamespace struct {
	Backend  ClientBackend
	Hostname string
}

func (UnitsNamespace) List

func (u UnitsNamespace) List(ctx context.Context) ([]SystemdUnit, error)

type VarsScope

type VarsScope struct {
	Backend  ClientBackend
	Hostname string
	Service  string
	Env      string
}

Vars

func (VarsScope) Delete

func (v VarsScope) Delete(ctx context.Context, key string) error

func (VarsScope) Get

func (v VarsScope) Get(ctx context.Context, key string) (string, error)

func (VarsScope) List

func (v VarsScope) List(ctx context.Context) (map[string]string, error)

func (VarsScope) Set

func (v VarsScope) Set(ctx context.Context, key, value string) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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