You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(server): load mocks from a file at startup (--init-mocks)
Add --init-mocks / SMOCKER_INIT_MOCKS: a YAML file of mocks (the exact POST
/mocks format) loaded into a fresh "init-mocks" session when the mocks service
is constructed. Useful for declarative, ephemeral setups (e.g. a Kubernetes
ConfigMap) where mocks should be present on boot without an API call.
It's read-only (never written back) and mutually exclusive with
--persistence-directory: seeding a fixed set and resuming/rewriting persisted
state are opposite intents, so setting both fails fast at startup.
Addresses #217 / #222.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
fs.StringVar(&c.StaticFiles, "static-files", "client", "Location of the static files to serve (index.html, etc.)")
41
41
fs.IntVar(&c.HistoryMaxRetention, "history-retention", 0, "Maximum number of calls to keep in the history per session (0 = no limit)")
42
42
fs.StringVar(&c.PersistenceDirectory, "persistence-directory", "", "If defined, the directory where the sessions will be synchronized")
43
+
fs.StringVar(&c.InitMocks, "init-mocks", "", "If defined, a YAML file of mocks (same format as POST /mocks) loaded into a session at startup; mutually exclusive with --persistence-directory")
43
44
fs.BoolVar(&c.TLSEnable, "tls-enable", false, "Enable TLS using the provided certificate")
44
45
fs.StringVar(&c.TLSCertFile, "tls-cert-file", "/etc/smocker/tls/certs/cert.pem", "Path to TLS certificate file ")
45
46
fs.StringVar(&c.TLSKeyFile, "tls-private-key-file", "/etc/smocker/tls/private/key.pem", "Path to TLS key file")
// Loading mocks at startup and persisting sessions are opposite intents: a seed file is a
110
+
// fixed, read-only starting point, while persistence resumes (and rewrites) whatever state it
111
+
// last held. Both define the boot state, so allowing both would be ambiguous on restart.
112
+
ifc.InitMocks!=""&&c.PersistenceDirectory!="" {
113
+
slog.Error("--init-mocks and --persistence-directory are mutually exclusive: seed mocks from a file (ephemeral) or persist sessions to a directory, not both")
0 commit comments