Skip to content

fix: include jq/yq in runtime image#45

Merged
overtrue merged 2 commits intomainfrom
fix/issue-43-add-jq-yq-20260309
Mar 9, 2026
Merged

fix: include jq/yq in runtime image#45
overtrue merged 2 commits intomainfrom
fix/issue-43-add-jq-yq-20260309

Conversation

@overtrue
Copy link
Contributor

@overtrue overtrue commented Mar 9, 2026

Summary

  • add jq and yq-go to the runtime image in Dockerfile
  • add a regression contract test to ensure the runtime image install line keeps both tools
  • keep scope limited to rustfs/cli issue Could we add jq/yq to the image? #43

Problem Validation

  • Reproduced against latest published image:
    • docker run --rm --entrypoint sh rustfs/rc:latest -lc 'jq --version; yq --version'
    • Result: both commands were not found

Root Cause

The runtime stage installed only ca-certificates, so jq and yq were unavailable in the container.

Fix

  • Runtime install line changed to:
    • apk add --no-cache ca-certificates jq yq-go

Similar Cases Checked

  • Checked this repository for additional runtime image definitions; only root Dockerfile builds the published CLI image.

Verification

  • cargo fmt --all --check
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test --workspace
  • docker run --rm --entrypoint sh rustfs/rc:latest -lc 'jq --version; yq --version' (repro before fix)

Linked Issue

Fixes #43

Copilot AI review requested due to automatic review settings March 9, 2026 11:13
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 required CLI-side tooling to the published runtime container image so rc users can rely on jq/yq being present (per issue #43), and introduces a regression contract test to prevent accidental removal in future Dockerfile edits.

Changes:

  • Install jq and yq-go in the runtime stage of the root Dockerfile.
  • Add a CLI contract test that asserts the Dockerfile installs these tools.

Reviewed changes

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

File Description
Dockerfile Extends the runtime stage apk add line to include jq and yq-go.
crates/cli/tests/dockerfile_contract.rs Adds a contract test to detect regressions in runtime image tool installation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +5 to +6
assert!(
dockerfile.contains("apk add --no-cache ca-certificates jq yq-go"),
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

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

The contract test is very brittle because it requires an exact substring with a fixed package order and no additional packages (e.g., adding another runtime tool or reformatting the RUN line would fail the test even if jq/yq-go are still installed). Consider asserting that the runtime-stage apk add --no-cache line includes both jq and yq-go regardless of ordering/extra packages (e.g., tokenize the line or use a regex) so the test only fails when the tools are actually removed.

Suggested change
assert!(
dockerfile.contains("apk add --no-cache ca-certificates jq yq-go"),
// Find the runtime-stage apk add line and ensure it includes both jq and yq-go,
// regardless of order or additional packages.
let runtime_apk_line = dockerfile
.lines()
.find(|line| line.contains("apk add --no-cache"))
.expect("runtime image must install packages via `apk add --no-cache`");
let mut has_jq = false;
let mut has_yq_go = false;
for token in runtime_apk_line.split_whitespace() {
if token == "jq" {
has_jq = true;
} else if token == "yq-go" {
has_yq_go = true;
}
}
assert!(
has_jq && has_yq_go,

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +2
#[test]
fn runtime_image_contains_jq_and_yq() {
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

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

For consistency with the other crates/cli/tests/* contract/golden/integration test files, consider adding a brief module-level //! doc comment describing what this contract test is protecting (and why it exists).

Copilot uses AI. Check for mistakes.
@overtrue
Copy link
Contributor Author

overtrue commented Mar 9, 2026

Addressed the review feedback in commit 3d548cf:

  • made dockerfile_contract parse only the runtime stage (FROM alpine:3.23)
  • made package assertions order-independent for jq and yq-go
  • added a module-level test doc comment for consistency

Re-ran cargo fmt --all --check and cargo test --workspace, both pass.

@mreiche
Copy link

mreiche commented Mar 9, 2026

Oh wow. Fixed without even a discussion. Thank you ❤️

@overtrue overtrue merged commit 2fdc371 into main Mar 9, 2026
15 checks passed
@overtrue overtrue deleted the fix/issue-43-add-jq-yq-20260309 branch March 9, 2026 13:04
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.

Could we add jq/yq to the image?

3 participants