feat: add --sidecar global flag (#25)#26
Merged
mikkeldamsgaard merged 1 commit intomainfrom Feb 25, 2026
Merged
Conversation
…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>
Contributor
There was a problem hiding this comment.
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
--sidecarglobal flag that logs a completion message and then sleeps indefinitely on success. - Add integration tests covering
--sidecarbehavior (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_or → is_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_SIDECARbehavior.
#[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:
restartPolicyis not a field underspec.containers[]. If the intent is to document KEP-753 sidecar containers (K8s 1.29+), the snippet should be underinitContainers:(where per-initContainerrestartPolicy: Alwaysis supported), or otherwise droprestartPolicyand keep it as a normalcontainers: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>.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--sidecarglobal flag (env:INITIUM_SIDECAR) that keeps the process alive after task completion, for use as a Kubernetes sidecar containerinconsistent_digit_grouping,manual_main_separator_str,unnecessary_map_or)Closes #25
Test plan
cargo clippy --all-targets --all-features -- -D warningspassescargo fmt -- --checkpassescargo test --all-features— all 163 tests passtest_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_successHow to verify
🤖 Generated with Claude Code