caprf

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package caprf implements the CAPRF provisioning server client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseVars

func ParseVars(r io.Reader) (*config.MachineConfig, error)

ParseVars reads a /deploy/vars file and returns a MachineConfig. The file format is: export KEY="VALUE" (one per line).

Types

type Client

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

Client communicates with the CAPRF provisioning server.

func New

func New(varsPath string) (*Client, error)

New creates a CAPRF client by parsing the vars file at the given path.

func NewFromConfig

func NewFromConfig(cfg *config.MachineConfig) *Client

NewFromConfig creates a CAPRF client from an already-parsed config.

func (*Client) AcknowledgeCommand added in v0.0.2

func (c *Client) AcknowledgeCommand(ctx context.Context, cmdID, status, message string) error

AcknowledgeCommand reports command execution result back to the CAPRF server.

func (*Client) FetchCommands

func (c *Client) FetchCommands(ctx context.Context) ([]config.Command, error)

FetchCommands polls the CAPRF server for pending commands. Returns nil if no commands URL is configured.

func (*Client) GetConfig

func (c *Client) GetConfig(_ context.Context) (*config.MachineConfig, error)

GetConfig returns the parsed machine configuration.

func (*Client) Heartbeat

func (c *Client) Heartbeat(ctx context.Context) error

Heartbeat sends a keepalive to the CAPRF server. Returns nil if no heartbeat URL is configured (non-standby mode).

func (*Client) ReportFirmware

func (c *Client) ReportFirmware(ctx context.Context, data []byte) error

ReportFirmware sends a JSON firmware report to the CAPRF server.

func (*Client) ReportHealthChecks

func (c *Client) ReportHealthChecks(ctx context.Context, results []health.CheckResult) error

ReportHealthChecks sends health check results to the CAPRF server.

func (*Client) ReportInventory

func (c *Client) ReportInventory(ctx context.Context, data []byte) error

ReportInventory posts a hardware inventory JSON payload to the CAPRF server.

func (*Client) ReportMetrics added in v0.0.2

func (c *Client) ReportMetrics(ctx context.Context, data []byte) error

ReportMetrics posts provisioning metrics to the CAPRF server. Requires TelemetryEnabled. Uses MetricsURL, falling back to TelemetryURL.

func (*Client) ReportStatus

func (c *Client) ReportStatus(ctx context.Context, status config.Status, message string) error

ReportStatus sends a provisioning status to the CAPRF server.

func (*Client) SendEvent added in v0.0.2

func (c *Client) SendEvent(ctx context.Context, data []byte) error

SendEvent posts a single provisioning event to the CAPRF server.

func (*Client) ShipDebug

func (c *Client) ShipDebug(ctx context.Context, message string) error

ShipDebug sends a debug message to the CAPRF /debug endpoint.

func (*Client) ShipLog

func (c *Client) ShipLog(ctx context.Context, message string) error

ShipLog sends a log line to the CAPRF /log endpoint.

type RemoteHandler

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

RemoteHandler is a slog.Handler that ships log lines to the CAPRF /log endpoint. It wraps another handler so logs appear both in the console and remotely.

func NewRemoteHandler

func NewRemoteHandler(client *Client, inner slog.Handler, level slog.Leveler, bufSize int) *RemoteHandler

NewRemoteHandler creates a handler that sends logs to the CAPRF server. The inner handler is used for local console output. Buffer capacity controls how many log lines can be queued before dropping.

func (*RemoteHandler) Close

func (h *RemoteHandler) Close()

Close stops the background drain goroutine and flushes remaining logs. Uses a timeout to prevent blocking shutdown indefinitely.

func (*RemoteHandler) Enabled

func (h *RemoteHandler) Enabled(_ context.Context, level slog.Level) bool

Enabled reports whether the handler handles records at the given level.

func (*RemoteHandler) Handle

func (h *RemoteHandler) Handle(ctx context.Context, r slog.Record) error

Handle sends the log record to both the inner handler and the remote buffer.

func (*RemoteHandler) WithAttrs

func (h *RemoteHandler) WithAttrs(attrs []slog.Attr) slog.Handler

WithAttrs returns a new handler with the given attributes.

func (*RemoteHandler) WithGroup

func (h *RemoteHandler) WithGroup(name string) slog.Handler

WithGroup returns a new handler with the given group name.

Jump to

Keyboard shortcuts

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