Documentation
¶
Index ¶
- Constants
- Variables
- type Arg
- type CPU
- type ComposeService
- type DirEntry
- type DockerEvent
- type Event
- type FileStat
- type Job
- type JobResult
- type JobStatus
- type JobUpdate
- type JournalEntry
- type LogLine
- type Memory
- type Metrics
- type Peer
- type Port
- type PortUpdate
- type Process
- type RawEvent
- type SendDirRequest
- type SendRequest
- type SendResult
- type TailkitPeer
- type Tool
Constants ¶
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" )
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 ¶
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") 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 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 DockerEvent ¶ added in v0.4.2
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 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 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 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.