Skip to content

Conversation

@vertti
Copy link
Owner

@vertti vertti commented Jan 1, 2026

Summary

  • Add -- command syntax that runs checks, then execs into the command
  • Enables preflight as ENTRYPOINT in distroless/scratch images (no shell needed)
  • Uses syscall.Exec on Unix to properly replace the process (correct PID 1 behavior)

Usage

# Wait for postgres, then start app (no shell required)
ENTRYPOINT ["/preflight", "tcp", "postgres:5432", "--retry", "10", "--"]
CMD ["/myapp"]

Works with any preflight command:

preflight tcp postgres:5432 --retry 10 -- ./myapp
preflight env DATABASE_URL -- ./myapp
preflight http localhost:8080/health -- ./myapp
preflight run -- ./myapp

Implementation

  • New pkg/exec package with platform-specific implementations
  • exec_unix.go: Uses syscall.Exec to replace current process
  • exec_windows.go: Returns error (not supported)
  • Main extracts -- args before Cobra parsing, execs after checks pass

Tests

  • Unit tests for extractExecArgs function
  • Unit tests for exec package
  • Integration tests that build preflight and verify exec mode works end-to-end

vertti added 3 commits January 1, 2026 12:27
Support `preflight <check> -- ./command` syntax that runs checks and
then execs into the specified command. Enables preflight as ENTRYPOINT
in distroless/scratch images without requiring a shell.

- Add pkg/exec package with platform-specific syscall.Exec
- Modify main.go to extract -- args and exec after checks pass
- Add integration tests for exec mode
- Document entrypoint mode in docs/usage.md
- Make execFunc injectable for testing
- Add Unix-specific tests that mock syscall.Exec
- Test argument passing, binary resolution, error handling
@codecov
Copy link

codecov bot commented Jan 1, 2026

Codecov Report

❌ Patch coverage is 84.61538% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.39%. Comparing base (d0f13c2) to head (4c20d15).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
cmd/preflight/main.go 73.33% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #80      +/-   ##
==========================================
- Coverage   91.49%   91.39%   -0.10%     
==========================================
  Files          45       47       +2     
  Lines        1799     1825      +26     
==========================================
+ Hits         1646     1668      +22     
- Misses        105      109       +4     
  Partials       48       48              
Files with missing lines Coverage Δ
pkg/exec/exec.go 100.00% <100.00%> (ø)
pkg/exec/exec_unix.go 100.00% <100.00%> (ø)
cmd/preflight/main.go 62.16% <73.33%> (+7.61%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@vertti vertti merged commit 189e283 into main Jan 1, 2026
17 checks passed
@vertti vertti deleted the add-exec-mode branch January 1, 2026 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants