Skip to content

feat: start mocks detached and target stop by mock ID#4

Open
outofcoffee wants to merge 1 commit into
mainfrom
feat/mock-id-inputs
Open

feat: start mocks detached and target stop by mock ID#4
outofcoffee wants to merge 1 commit into
mainfrom
feat/mock-id-inputs

Conversation

@outofcoffee
Copy link
Copy Markdown
Contributor

Start mocks detached (waiting for the healthcheck) and stop a specific mock by ID, with a shared ID file linking the two.

Summary

  • start-mocks now runs imposter up --detach=healthy: the CLI backgrounds the mock and waits for the healthcheck itself, replacing the hand-rolled curl polling loop.
  • New mock-id-file input on start-mocks writes the started mock's ID (via --id-file) so it can be torn down precisely later.
  • stop-mocks gains mock-id and mock-id-file inputs to stop a single mock by ID or from an ID file; with neither set it still stops every managed mock (--all).
  • Deprecated the now-unused auto-restart, max-attempts and retry-interval inputs on start-mocks (they have no effect under the detached start), warning if they are set.
  • Updated the README examples and sample workflow to show the start→stop ID round-trip.

Implementation details

  • These rely on imposter-cli's --detach and --id-file flags. --detach=healthy blocks until the healthcheck passes, so the step completes only when the mock is ready — and the detached process survives the step, which is more robust than the previous & backgrounding (notably for non-docker engines).
  • --detach is incompatible with auto-restart in the CLI (the config-dir watcher lives in the foreground process, which exits once the mock is backgrounded), which is why those polling/restart inputs are deprecated rather than rewired.
  • User-controlled inputs are passed to the shell via environment variables rather than direct ${{ }} interpolation, to avoid script injection.

Rewrite start-mocks to use 'imposter up --detach=healthy', so the CLI
backgrounds the mock and waits for the healthcheck itself, replacing the
manual curl loop. Add a mock-id-file input that writes the started mock
ID via --id-file.

Add mock-id and mock-id-file inputs to stop-mocks so a single mock can
be stopped by ID or from an ID file, falling back to stopping all mocks.

Deprecate the now-unused auto-restart, max-attempts and retry-interval
inputs, which no longer have any effect with the detached start.
@outofcoffee outofcoffee added the enhancement New feature or request label May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant