Documentation
¶
Overview ¶
Package inventory is the deployment-tracking model. Keyed by SHA256 fingerprint, it turns rotation into a checklist and is persisted atomically.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComputeExpiry ¶
ComputeExpiry returns created (YYYY-MM-DD) + rotateAfterDays as YYYY-MM-DD.
func IsArchivedPath ¶
IsArchivedPath reports whether path is a rotation's /old/ predecessor slot, i.e. .../profiles/[<category>/]<profile>/old/<key_name> (by structure, so a profile literally named "old" is not mistaken for an archived key).
Types ¶
type Deployment ¶
type Deployment struct {
Target string `json:"target"`
Method string `json:"method"` // ssh-copy-id | web-panel | manual | <adapter>
Date *string `json:"date"`
Verified bool `json:"verified"` // false == needs-redeploy
}
Deployment records a key installed on one target.
func (*Deployment) UnmarshalJSON ¶
func (d *Deployment) UnmarshalJSON(b []byte) error
type Inventory ¶
Inventory is the whole inventory, keyed by fingerprint.
func (*Inventory) Save ¶
Save writes the inventory as indented JSON, atomically.
Via a temp file and a rename, not os.WriteFile: WriteFile truncates the target and then writes, so a crash or a full disk mid-write leaves a truncated inventory - the record of every key's expiry and deployments, lost to a partial write. It also keeps whatever mode the file already had, so an inventory that had somehow become group-readable stayed that way.
func (*Inventory) UnmarshalJSON ¶
type KeyRecord ¶
type KeyRecord struct {
Profile string `json:"profile"`
Path string `json:"path"`
Type string `json:"type"`
Comment *string `json:"comment"`
Created *string `json:"created"`
RotateAfterDays int `json:"rotate_after_days"`
ExpiresOn *string `json:"expires_on"`
Deployments []Deployment `json:"deployments"`
}
KeyRecord is one managed key and where it is deployed. All fields serialize unconditionally (null for an unset pointer, [] for no deployments) to match the serializer v1 and v2 used, byte-for-byte.
func (KeyRecord) MarshalJSON ¶
MarshalJSON emits a nil Deployments slice as [] (not null), matching the default_factory=list. The pointer fields already emit null when unset.
func (KeyRecord) NeedsRedeploy ¶
NeedsRedeploy is true when no deployment is verified (e.g. a fresh key).