Documentation
¶
Overview ¶
Package policy holds Guard Mode's remote budget policies: the caps a Goei team owner set that this device enforces locally. Policies are fetched from the Goei server (via GET /api/policy or the sync-response piggyback), cached on disk so enforcement survives a network blip and a restart, and never invent a stricter rule than the server sent.
Remote policies are kept OUT of the user's config.toml on purpose: that file is hand-editable and its TOML round-trip drops comments, so mixing server-owned rules into it would clobber user intent. The cache is a separate, machine-managed JSON file.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Bundle ¶
type Bundle struct {
PolicyVersion int `json:"policyVersion"`
ETag string `json:"etag"`
FetchedAt string `json:"fetchedAt"`
Policies []Policy `json:"policies"`
}
Bundle is the cached policy set plus the ETag needed for a cheap conditional refresh and the time it was fetched (shown in `guard status`).
func BundleFromResponse ¶
func BundleFromResponse(pr *goei.PolicyResponse, etag, fetchedAt string) *Bundle
BundleFromResponse builds a cacheable Bundle from a server response.
type Policy ¶
type Policy struct {
ID string `json:"id"`
ScopeType string `json:"scopeType"` // team | project | dev
ScopeValue string `json:"scopeValue"` // "" | project name
Period string `json:"period"` // day | week | month
CapCents int `json:"capCents"`
Enforcement string `json:"enforcement"` // local_exact | server_aggregate
Action string `json:"action"` // warn | kill
ServerSpentCents int `json:"serverSpentCents"`
AsOf string `json:"asOf"`
SetBy string `json:"setBy"`
}
Policy is one remote budget cap, resolved for this device.
func FromWire ¶
func FromWire(w goei.WirePolicy) Policy
FromWire converts one server WirePolicy into a Policy.
func LocalExact ¶
LocalExact returns only the locally-enforceable policies.
func (Policy) IsLocalExact ¶
IsLocalExact reports whether this policy is enforceable against the local rollup (and thus kill-eligible). Server-aggregate policies are warn-only.