Documentation
¶
Overview ¶
Package seed loads a YAML or JSON seed file into the mock's in-memory stores: expectations, claims, claim mappings, permissions and the MFA flag.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type File ¶
type File struct {
Expectations []Item `json:"expectations,omitempty"`
Claims map[string]any `json:"claims,omitempty"`
ClaimMappings map[string]string `json:"claim_mappings,omitempty"`
Permissions map[string][]string `json:"permissions,omitempty"`
MFARequired bool `json:"mfa_required,omitempty"`
}
File is the on-disk shape of a seed file, shared with the export.
func Export ¶
Export dumps the current state of st in seed file shape. Bodies are normalised (sorted keys, exact numbers) so the output is stable. When detail is true each expectation also carries its id and hit count.
type Item ¶
type Item struct {
ID string `json:"id,omitempty"`
matches.Registration
Hits *int64 `json:"hits,omitempty"`
}
Item is one expectation entry. ID and Hits appear in exports; they are accepted on load and ignored.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager owns the seed file: it applies it at startup, re-applies it on reset and reloads it when its content changes.
func NewManager ¶
NewManager reads and parses the seed file at path and applies it to st.
func (*Manager) Bind ¶
Bind sets the function that clears every store. It must be called before Reset, Poll or Watch.
func (*Manager) Export ¶
Export snapshots the stores in seed file shape while holding the lock Reset and Poll hold, so it never sees a half-applied reload.
type Seed ¶
type Seed struct {
Expectations []matches.Expectation
Claims map[string]any
ClaimMappings map[string]string
Permissions map[string][]string
MFARequired bool
}
Seed is a parsed, validated seed file.
func Parse ¶
Parse reads YAML (or JSON, which is a subset) and validates every expectation against the Management API spec.