Documentation
¶
Overview ¶
Package client is a thin, ready-to-use gRPC client for the LabManager agent. It handles connection setup and mutual TLS so a caller (e.g. the control plane) only imports this package and calls the typed LabManager RPCs.
Ported from the legacy agent's client wrapper, adapted to the LabManager contract and to mTLS (the LabManager agent authenticates callers by client certificate + CN allowlist, not a JWT token).
Index ¶
Constants ¶
const ( MaxMessageSize = 64 << 20 MaxRequestSize = 4 << 20 MaxItems = 5000 )
MaxMessageSize is the largest answer the client accepts, equal to the agent's send limit; MaxRequestSize is the largest request it sends, equal to what the agent reads (a bigger one is refused locally); MaxItems is the most items one call may carry.
const ( // ErrorDomain is the errdetails.ErrorInfo domain of agent-specific errors. ErrorDomain = "agent.cybericebox" // ReasonTerminating is the ErrorInfo reason of a write refused because the // object with that deterministic name is still being deleted (finalizers run // asynchronously). The write was NOT applied; retry after a short delay. ReasonTerminating = "TERMINATING" )
const ReasonCountMismatch = "COUNT_MISMATCH"
ReasonCountMismatch is the ErrorInfo reason of a selector call refused because more objects matched than the call's expected_count. Nothing was done.
Variables ¶
This section is empty.
Functions ¶
func CountMismatch ¶
CountMismatch reports whether err is the agent's expected_count refusal (codes.FailedPrecondition + reason COUNT_MISMATCH) and the actual number of objects the selector matched.
func IsTerminating ¶
IsTerminating reports whether err is the agent's retryable "object is still being deleted" refusal (codes.Unavailable + ErrorInfo reason TERMINATING). The object's deletion is finished once Get* returns codes.NotFound.
Types ¶
type Client ¶
type Client interface {
protobuf.LabManagerClient
Close() error
}
Client is the typed LabManager client plus connection ownership.
func NewConnection ¶
NewConnection dials the LabManager agent and returns a typed client. The caller owns the connection and must Close it. grpc.NewClient is lazy — the actual connection is established on the first RPC.
type Config ¶
type Config struct {
// Endpoint is the agent address, host:port. Dial the agent by its
// certificate hostname (the agent's domain): gRPC then uses that as the
// TLS SNI and verifies it against the server certificate SAN, so no
// separate server-name setting is needed.
Endpoint string
TLS TLS
}
Config describes how to reach a LabManager agent.
type TLS ¶
type TLS struct {
Enabled bool
CertFile string // client certificate (PEM) presented for mTLS
KeyFile string // client private key (PEM)
CAFile string // CA (PEM) that signed the agent's server certificate; empty = system roots
}
TLS configures the transport. When Enabled, the connection is mutual TLS: the client presents CertFile/KeyFile (whose CN must be a Tenant) and verifies the server against CAFile, or against the system roots when CAFile is empty (a publicly trusted certificate). With no CertFile and KeyFile it is server-authenticated TLS only, for Enroll.