Documentation
¶
Overview ¶
Package caprf implements the CAPRF provisioning server client.
Index ¶
- func ParseVars(r io.Reader) (*config.MachineConfig, error)
- type Client
- func (c *Client) AcknowledgeCommand(ctx context.Context, cmdID, status, message string) error
- func (c *Client) FetchCommands(ctx context.Context) ([]config.Command, error)
- func (c *Client) GetConfig(_ context.Context) (*config.MachineConfig, error)
- func (c *Client) Heartbeat(ctx context.Context) error
- func (c *Client) ReportFirmware(ctx context.Context, data []byte) error
- func (c *Client) ReportHealthChecks(ctx context.Context, results []health.CheckResult) error
- func (c *Client) ReportInventory(ctx context.Context, data []byte) error
- func (c *Client) ReportMetrics(ctx context.Context, data []byte) error
- func (c *Client) ReportStatus(ctx context.Context, status config.Status, message string) error
- func (c *Client) SendEvent(ctx context.Context, data []byte) error
- func (c *Client) ShipDebug(ctx context.Context, message string) error
- func (c *Client) ShipLog(ctx context.Context, message string) error
- type RemoteHandler
- func (h *RemoteHandler) Close()
- func (h *RemoteHandler) Enabled(_ context.Context, level slog.Level) bool
- func (h *RemoteHandler) Handle(ctx context.Context, r slog.Record) error
- func (h *RemoteHandler) WithAttrs(attrs []slog.Attr) slog.Handler
- func (h *RemoteHandler) WithGroup(name string) slog.Handler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client communicates with the CAPRF provisioning server.
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
AcknowledgeCommand reports command execution result back to the CAPRF server.
func (*Client) FetchCommands ¶
FetchCommands polls the CAPRF server for pending commands. Returns nil if no commands URL is configured.
func (*Client) Heartbeat ¶
Heartbeat sends a keepalive to the CAPRF server. Returns nil if no heartbeat URL is configured (non-standby mode).
func (*Client) ReportFirmware ¶
ReportFirmware sends a JSON firmware report to the CAPRF server.
func (*Client) ReportHealthChecks ¶
ReportHealthChecks sends health check results to the CAPRF server.
func (*Client) ReportInventory ¶
ReportInventory posts a hardware inventory JSON payload to the CAPRF server.
func (*Client) ReportMetrics ¶ added in v0.0.2
ReportMetrics posts provisioning metrics to the CAPRF server. Requires TelemetryEnabled. Uses MetricsURL, falling back to TelemetryURL.
func (*Client) ReportStatus ¶
ReportStatus sends a provisioning status to the CAPRF server.
func (*Client) SendEvent ¶ added in v0.0.2
SendEvent posts a single provisioning event to the CAPRF server.
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 ¶
Enabled reports whether the handler handles records at the given level.
func (*RemoteHandler) Handle ¶
Handle sends the log record to both the inner handler and the remote buffer.