types

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2026 License: MIT Imports: 9 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"

	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")
)

Functions

This section is empty.

Types

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 added in v0.4.0

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 ComposeService

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

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 Event added in v0.4.0

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.

type FileStat added in v0.3.0

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

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 added in v0.4.0

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 added in v0.3.4

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 added in v0.3.4

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 Memory added in v0.4.0

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

type Metrics added in v0.4.0

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 Peer

type Peer struct {
	Status  ipnstate.PeerStatus `json:"status"`
	Tailkit *TailkitPeer        `json:"tailkit"`
}

specific tool installed.

type Port added in v0.4.0

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 added in v0.4.0

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 added in v0.4.0

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 added in v0.4.0

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 TailkitPeer

type TailkitPeer struct {
	Status ipnstate.PeerStatus `json:"status"`
	Tools  []Tool              `json:"tools"`
}

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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