devstubs

package
v0.0.0-...-3776344 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 5, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

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

type EndpointDef struct {
	Method string `yaml:"method"`
	Path   string `yaml:"path"`
}

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 MountebankStub struct {
	Predicates []any `json:"predicates"`
	Responses  []any `json:"responses"`
}

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

type ValidationError struct {
	Service  string
	File     string
	StubName string
	Message  string
}

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL