Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadImposters ¶
func LoadImposters(ctx context.Context, mountebankURL string, imposters []MountebankImposter) error
LoadImposters creates imposters in a running mountebank instance via its REST API.
Types ¶
type EndpointDef ¶
EndpointDef identifies the HTTP endpoint this stub file covers.
type EndpointStubFile ¶
type EndpointStubFile struct {
Endpoint EndpointDef `yaml:"endpoint"`
Stubs []StubDef `yaml:"stubs"`
}
EndpointStubFile is the structure of a single endpoint stub file (e.g., stubs/<service>/charges.yaml).
type LoadedService ¶
type LoadedService struct {
Name string
Config ServiceConfig
Endpoints []EndpointStubFile
}
LoadedService is the fully loaded and parsed stub configuration for a single service directory.
func LoadStubs ¶
func LoadStubs(appDir string) ([]LoadedService, error)
LoadStubs reads all service directories under <appDir>/stubs/ and returns the loaded service configurations with their endpoint stubs. Returns nil with no error if the stubs directory does not exist.
type MountebankImposter ¶
type MountebankImposter struct {
Port int `json:"port"`
Protocol string `json:"protocol"`
Name string `json:"name,omitempty"`
DefaultResponse map[string]any `json:"defaultResponse,omitempty"`
Stubs []MountebankStub `json:"stubs"`
}
func ToImposters ¶
func ToImposters(services []LoadedService) []MountebankImposter
ToImposters converts loaded services into mountebank imposter payloads. Each service becomes one imposter on its configured port. The endpoint method and path are prepended as an equals predicate to each stub.
type MountebankStub ¶
type ServiceConfig ¶
type ServiceConfig struct {
Port int `yaml:"port"`
ConfigKey string `yaml:"configKey"`
ConfigNamespace string `yaml:"configNamespace,omitempty"`
DefaultResponse map[string]any `yaml:"defaultResponse,omitempty"`
}
ServiceConfig is the service-level configuration parsed from stubs/<service>/service.yaml.
type StubDef ¶
type StubDef struct {
Name string `yaml:"name"`
Predicates []any `yaml:"predicates,omitempty"`
Responses []any `yaml:"responses"`
}
StubDef is a single stub scenario for an endpoint. Predicates and Responses use mountebank's native format.
type ValidationError ¶
ValidationError describes a single validation issue.
func ValidateStubs ¶
func ValidateStubs(services []LoadedService) []ValidationError
ValidateStubs checks all loaded services for configuration errors.
func (ValidationError) Error ¶
func (e ValidationError) Error() string