cloud

package
v0.0.0-...-d8c4ca1 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: AGPL-3.0 Imports: 27 Imported by: 0

Documentation

Overview

Package cloud is DockTail's optional reporting module for DockTail Cloud. It is completely inert unless DOCKTAIL_CLOUD_KEY is set: with no key, none of it runs and no connection is opened. When enabled, it subscribes to the reconciler's results, periodically self-discovers Docker services for an authoritative cloud snapshot, watches docker failure signals, runs local-vantage checks, and streams metadata to the cloud over an outbound WSS link.

The protocol is metadata-only by design (see ./proto): there are no exec/deploy/shell message types and this module never executes anything on the host. It depends only on the reconciler, the docker/tailscale clients, and the proto package — never on the proprietary cloud.

Index

Constants

View Source
const (
	EnvKey = "DOCKTAIL_CLOUD_KEY"
	// EnvURL overrides the baked-in ingest endpoint (proto.DefaultEndpoint).
	// It is a documented local-development escape hatch, not production
	// customer configuration.
	EnvURL = "DOCKTAIL_CLOUD_URL"
	// EnvAllowInsecure permits an explicitly configured ws:// endpoint whose
	// host is not loopback. It is a development-only escape hatch.
	EnvAllowInsecure = "DOCKTAIL_CLOUD_ALLOW_INSECURE"
	EnvLogLevel      = "DOCKTAIL_LOG_LEVEL"
	EnvCheckPeriod   = "DOCKTAIL_CHECK_INTERVAL"
)

Environment variables. The operator's required config is exactly one var (DOCKTAIL_CLOUD_KEY); everything else has a sane default.

View Source
const (
	DefaultCheckInterval = 30 * time.Second
	DefaultLogLevel      = "info"
	MinCheckInterval     = time.Duration(proto.MinCheckIntervalMS) * time.Millisecond
	MaxCheckInterval     = time.Duration(proto.MaxCheckIntervalMS) * time.Millisecond
)

Defaults.

Variables

This section is empty.

Functions

func Enabled

func Enabled() bool

Enabled reports whether the cloud module is active. DockTail runs exactly as before unless a workspace key is present.

Types

type Collector

type Collector struct {
	// contains filtered or unexported fields
}

Collector is DockTail's cloud reporting module. It implements reconciler.Observer: it receives the reconciler's computed services and the docker event stream, maps them to wire messages, and streams them over an outbound WSS connection it manages itself. It also runs local-vantage checks and a heartbeat while connected.

func NewCollector

func NewCollector(ctx context.Context, cfg Config, dc *docker.Client, ts tailnetSource, logger zerolog.Logger) (*Collector, error)

NewCollector builds a Collector, reading the host fingerprint (docker engine ID) and versions up front. Returns an error only if the engine ID can't be read — without it there is no stable host identity. ts is the local tailscale daemon reader used to source the tailnet vantage from the host's own netmap; pass nil (or a client with no tailnet) to run without the tailnet vantage.

func (*Collector) Fingerprint

func (c *Collector) Fingerprint() string

Fingerprint is the docker engine ID used as the host identity.

func (*Collector) OnEvent

func (c *Collector) OnEvent(ctx context.Context, msg events.Message)

OnEvent maps a docker event to wire events and (if connected) sends them, capturing a log excerpt for opted-in services on down signals.

func (*Collector) OnReconcile

func (c *Collector) OnReconcile(ctx context.Context, services []*apptypes.ContainerService)

OnReconcile receives the reconciler's freshly computed services, enriches them with runtime detail, stores them, and (if connected) sends a snapshot.

func (*Collector) Run

func (c *Collector) Run(ctx context.Context)

Run is the reconnect loop. It blocks until ctx is cancelled. Each iteration dials, performs the hello handshake, and (on accept) serves until the connection drops, then backs off — unless the rejection is terminal.

type Config

type Config struct {
	Key           string        // workspace key (dtc_...). Empty means disabled.
	URL           string        // WSS ingest endpoint.
	AllowInsecure bool          // development-only non-loopback ws:// escape hatch.
	LogLevel      string        // zerolog level name (informational; main owns logging).
	CheckInterval time.Duration // how often local-vantage checks run.
}

Config is the resolved cloud-module configuration.

func LoadConfig

func LoadConfig() Config

LoadConfig reads the cloud configuration from the environment, applying defaults.

func (Config) ZerologLevel

func (c Config) ZerologLevel() zerolog.Level

ZerologLevel maps the configured level name onto a zerolog.Level.

Directories

Path Synopsis
Package proto defines the wire contract between the DockTail agent (this repo, AGPL) and DockTail Cloud's proprietary agent-plane.
Package proto defines the wire contract between the DockTail agent (this repo, AGPL) and DockTail Cloud's proprietary agent-plane.

Jump to

Keyboard shortcuts

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