Skip to content

feat: add --sidecar global flag (#25)#26

Merged
mikkeldamsgaard merged 1 commit intomainfrom
feature/25-sidecar-flag
Feb 25, 2026
Merged

feat: add --sidecar global flag (#25)#26
mikkeldamsgaard merged 1 commit intomainfrom
feature/25-sidecar-flag

Conversation

@mikkeldamsgaard
Copy link
Contributor

Summary

  • Adds --sidecar global flag (env: INITIUM_SIDECAR) that keeps the process alive after task completion, for use as a Kubernetes sidecar container
  • On success: logs completion message and sleeps indefinitely
  • On failure: exits with code 1 immediately (no sleep)
  • Fixes pre-existing clippy warnings for newer Rust toolchain (inconsistent_digit_grouping, manual_main_separator_str, unnecessary_map_or)

Closes #25

Test plan

  • cargo clippy --all-targets --all-features -- -D warnings passes
  • cargo fmt -- --check passes
  • cargo test --all-features — all 163 tests pass
  • New tests: test_sidecar_flag_on_failure_exits_immediately, test_sidecar_flag_on_success_sleeps, test_sidecar_env_var, test_sidecar_logs_message_on_success, test_without_sidecar_exits_on_success

How to verify

# Build
cargo build

# Verify --sidecar keeps process alive on success (Ctrl+C to stop)
./target/debug/initium --sidecar exec -- true

# Verify --sidecar exits immediately on failure
./target/debug/initium --sidecar wait-for --target tcp://localhost:1 --timeout 1s --max-attempts 1

# Verify env var works (Ctrl+C to stop)
INITIUM_SIDECAR=true ./target/debug/initium exec -- true

# Run tests
cargo test --all-features
cargo clippy --all-targets --all-features -- -D warnings

🤖 Generated with Claude Code

…letion (#25)

When running as a Kubernetes sidecar container, the process needs to stay
alive after completing its tasks. The new --sidecar flag (env: INITIUM_SIDECAR)
causes the process to sleep indefinitely on success, while still exiting
immediately with code 1 on failure.

Also fixes pre-existing clippy warnings for newer Rust toolchain.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings February 25, 2026 19:48
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new global --sidecar / INITIUM_SIDECAR flag so initium can stay alive after successful completion (useful for Kubernetes sidecar-container patterns), plus a few small Rust/clippy-modernization tweaks.

Changes:

  • Add --sidecar global flag that logs a completion message and then sleeps indefinitely on success.
  • Add integration tests covering --sidecar behavior (success sleeps; failure exits; env var support; log message).
  • Fix a few clippy warnings / minor stdlib API modernizations in tests.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/main.rs Adds --sidecar flag and the post-success infinite sleep behavior.
tests/env_var_flags.rs Adds test coverage for --sidecar and INITIUM_SIDECAR.
docs/usage.md Documents the new flag and sidecar mode usage.
README.md Adds a quick “sidecar container” usage section.
tests/integration_test.rs Minor clippy-related refactor (map_oris_ok_and).
src/safety.rs Minor clippy-related refactor (MAIN_SEPARATOR usage).
src/duration.rs Minor clippy-related refactor (digit grouping).
Comments suppressed due to low confidence (3)

src/main.rs:36

  • The project design/contribution guide calls out updating CHANGELOG.md for new user-facing features (see docs/design.md:101-106), but this PR introduces a new global flag without adding an entry. Please add a short note under the Unreleased section describing the new --sidecar / INITIUM_SIDECAR behavior.
    #[arg(
        long,
        global = true,
        env = "INITIUM_SIDECAR",
        help = "Keep process alive after task completion (for sidecar containers)"
    )]
    sidecar: bool,

docs/usage.md:398

  • This Kubernetes YAML example is invalid as written: restartPolicy is not a field under spec.containers[]. If the intent is to document KEP-753 sidecar containers (K8s 1.29+), the snippet should be under initContainers: (where per-initContainer restartPolicy: Always is supported), or otherwise drop restartPolicy and keep it as a normal containers: entry.
# Kubernetes sidecar example (requires K8s 1.29+)
containers:
  - name: initium-sidecar
    image: ghcr.io/kitstream/initium:latest
    restartPolicy: Always
    args: ["--sidecar", "wait-for", "--target", "tcp://postgres:5432"]
**README.md:220**
* This Kubernetes snippet uses `containers:` with `restartPolicy: Always`, but `restartPolicy` is not valid under `spec.containers[]`. For KEP-753 sidecar containers (K8s 1.29+), this should likely be shown under `initContainers:` with `restartPolicy: Always`, or else remove `restartPolicy` if you intend a regular long-running container.
containers:
  - name: initium-sidecar
    image: ghcr.io/kitstream/initium:latest
    restartPolicy: Always
    args: ["--sidecar", "wait-for", "--target", "tcp://postgres:5432"]
</details>



---

💡 <a href="/KitStream/initium/new/main?filename=.github/instructions/*.instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add Copilot custom instructions</a> for smarter, more guided reviews. <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn how to get started</a>.

@mikkeldamsgaard mikkeldamsgaard merged commit 3935d76 into main Feb 25, 2026
9 checks passed
@mikkeldamsgaard mikkeldamsgaard deleted the feature/25-sidecar-flag branch February 26, 2026 19:00
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.

Add global --sidecar flag to keep process alive after task completion

2 participants