manifest/bazel: customer flag passthrough (--bazel-flag, --bazel-startup-flag, --bazel-maven-repo)#1343
Draft
Simon (simonhj) wants to merge 1 commit into
Conversation
5b192f5 to
cb89c15
Compare
… non-conventional hubs
Adds three repeatable CLI flags so customers can drive the underlying
bazel invocations without having to fork the orchestrator:
--bazel-flag=<arg> appended to every subcommand (cquery, query,
mod show_extension, mod dump_repo_mapping)
after the orchestrator's own flags. Use for
matrix-cell selectors:
--bazel-flag=--repo_env=SCALA_VERSION=2.13.18
--bazel-flag=--config=ci-scala-2-13
--bazel-flag=--platforms=//tools:linux_x86_64
--bazel-startup-flag=<arg> injected into the startup-flag prefix BEFORE
the subcommand, after the orchestrator's
startup flags (--bazelrc, --output_user_root,
--output_base). Use for host-side knobs:
--bazel-startup-flag=--host_jvm_args=-Xmx2g
--bazel-maven-repo=<name> appended to the candidate Maven hub list. Use
on legacy WORKSPACE workspaces whose hubs
use non-conventional names that the
conventional probe list doesn't cover, or on
custom Bzlmod extensions `mod show_extension`
doesn't enumerate:
--bazel-maven-repo=my_jars
--bazel-maven-repo=test_maven (repeatable)
`BazelQueryOptions` gains `extraBazelFlags` and `extraBazelStartupFlags`;
the centralised `buildStartupFlags` and the new `userBazelFlags`
helpers thread them through every argv builder uniformly (probe
cquery, metadata cquery in bazel-cquery, query, mod show_extension,
mod dump_repo_mapping). `ExtractBazelOptions` gains the matching three
fields, defaulted to undefined when no CLI override was supplied.
Flag passthrough is verbatim — Bazel's last-wins precedence handles
conflicts between socket.json defaults (`bazelFlags`) and CLI overrides
(`extraBazelFlags`). No allowlist; the trust model is the same as
running `bazel` directly, and per-invocation `--output_user_root`
isolation prevents a hostile flag from poisoning shared state.
Tests cover argv shape for both extra-flag arrays (placement before
subcommand for startup flags; placement after standard subcommand
flags for trailing flags), the cquery argv-shape test, and the
extraMavenRepoNames threading end-to-end.
bec0ccf to
414a9a6
Compare
cb89c15 to
3346783
Compare
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
Adds three repeatable CLI flags to
socket manifest bazelso customerscan drive the underlying bazel invocations without forking the
orchestrator: matrix-cell selection, host-side JVM tuning, and
non-conventional Maven hub naming.
Stacks on top of the nested-workspace + Bazel-native extraction PR.
Reviewable independently once that one lands.
The three flags
Plumbing
BazelQueryOptionsgainsextraBazelFlagsandextraBazelStartupFlags; the centralisedbuildStartupFlagsand thenew
userBazelFlagshelpers thread them through every argv builderuniformly (probe cquery, metadata cquery in
bazel-cquery, query,mod show_extension,mod dump_repo_mapping).ExtractBazelOptionsgains the matching three fields, defaulted to undefined when no CLI
override was supplied.
Trust model
Flag passthrough is verbatim — Bazel's last-wins precedence handles
conflicts between socket.json defaults (
bazelFlags) and CLIoverrides (
extraBazelFlags). No allowlist; the user invoking the CLIcan already run
bazeldirectly with these flags. Per-invocation--output_user_rootisolation (from the base PR) prevents a hostileflag from poisoning shared Bazel state across CLI runs.
Tests
Argv-shape assertions for both extra-flag arrays:
bazelFlagsandextraBazelFlagsbothset the same flag;
outputUserRootstartup-flag placement vs.extraBazelStartupFlags;extraMavenRepoNamesthreading through the orchestrator end-to-end(probe accepts only
my_jars; conventional names returnnot-defined; metadata cquery runs once against@my_jars//...).220 bazel-module tests pass; project typecheck clean.
Test plan