Documentation
¶
Overview ¶
Package guard is the ceremony between a developer and a destructive action.
A developer holding a prod context in the same switcher as qa will eventually act on the wrong one. Every layer here exists because designing against that beats trusting attention:
- the environment's name travels with every gate, never inferred from memory
- the write policy comes from the environment, not from the screen
- a confirm environment wants the resource name typed, the pattern people already know from deleting a GitHub repository
- break-glass unlocks production for fifteen minutes with a stated reason, then re-locks itself
- the blast radius and the equivalent kubectl travel with the gate, so nobody confirms something they have not seen
- a gate is always about exactly one environment
One boundary, stated plainly and repeated in the docs: these layers protect against accidents, not against intent. The write policy lives in a config file the user controls and can edit in a second. RBAC is the security boundary; this is ergonomics on top of it and never a substitute for it.
Index ¶
Constants ¶
const ( RequireNothing = "" RequireTypedName = "typed-name" RequireBreakGlass = "break-glass" )
What the UI must collect before the action may run.
const BreakGlassWindow = 15 * time.Minute
BreakGlassWindow is how long production stays armed after an unlock. Long enough to finish an incident action, short enough that nobody leaves prod unlocked by forgetting.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Action ¶
type Action struct {
Verb string
Resource string
Name string
Namespace string
// Kubectl is the equivalent command. Showing it is how somebody checks the
// tool's understanding against their own before agreeing to it.
Kubectl string
Blast Blast
}
Action is the thing somebody is about to do.
type Blast ¶
type Blast struct {
Pods int `json:"pods"`
Summary string `json:"summary,omitempty"`
// Unknown marks a radius nobody computed. Rendering it as zero would be a
// claim nobody made.
Unknown bool `json:"unknown,omitempty"`
}
Blast is what an action touches.
type Gate ¶
type Gate struct {
Permitted bool `json:"permitted"`
Require string `json:"require,omitempty"`
Confirm string `json:"confirm,omitempty"`
Environment string `json:"environment"`
Risk string `json:"risk"`
Policy string `json:"policy"`
Reason string `json:"reason,omitempty"`
Kubectl string `json:"kubectl,omitempty"`
Blast Blast `json:"blast"`
// UnlockedUntil is when a break-glass window closes, empty when locked.
UnlockedUntil string `json:"unlockedUntil,omitempty"`
}
Gate is the answer: whether the action may proceed, and what it costs.
type Guard ¶
type Guard struct {
// contains filtered or unexported fields
}
Guard holds the break-glass windows. They live in memory and die with the process, like everything else: a tool that remembers prod was unlocked yesterday is a tool that unlocks prod tomorrow.
func (*Guard) Check ¶
func (g *Guard) Check(contextName string, env environments.Environment, a Action) Gate
Check answers whether one action may proceed in one environment.