Skip to content

SOLR-17697: Implement picocli for auth command / AuthTool - #4684

Open
janhoy wants to merge 2 commits into
apache:jira/SOLR-17697-picoclifrom
janhoy:jira/SOLR-17697-picocli-auth
Open

SOLR-17697: Implement picocli for auth command / AuthTool#4684
janhoy wants to merge 2 commits into
apache:jira/SOLR-17697-picoclifrom
janhoy:jira/SOLR-17697-picocli-auth

Conversation

@janhoy

@janhoy janhoy commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Adds picocli support to AuthTool following the established dual-path pattern:

  • Business logic extracted from the commons-cli-coupled handleBasicAuth(CommandLine) into enableBasicAuth/disableBasicAuth operating on a shared AuthParams record plus a pluggable zk-host resolver, so both parsing paths run identical code.
  • @Command annotation with examples and exit codes; enable|disable as a positional parameter; options mirror the commons-cli definitions, with connection/credentials options provided by the ZkConnectionOptions mixin (includes the new -s/--solr-connection).
  • AuthTool registered as a SolrCLI subcommand; generated solr-auth.adoc ref-guide page included.
  • AuthToolPicocliTest runs the whole existing AuthToolTest suite through picocli.CommandLine.execute().

Boolean-ish options (--block-unknown etc.) stay string-typed so both paths emit the same validation message asserted by test_auth.bats. Connection parsing remains string-only; no I/O happens during argument parsing.

Verified: AuthToolTest + AuthToolPicocliTest green, test_auth.bats green on the commons-cli path and the picocli path (SOLR_PICOCLI=true), check -x test with Error Prone.

@github-actions github-actions Bot added documentation Improvements or additions to documentation tests cat:cli labels Jul 30, 2026
}

private void clearSecurityJson(CommandLine cli, boolean updateIncludeFileOnly) throws Exception {
private void clearSecurityJson(boolean updateIncludeFileOnly, Callable<String> zkHostResolver)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does Callable<String> zkHostResolver work better than just zkHost? Just wondering if we actually need a powerful "Callable"....

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

True, both call paths can resolve zkHost lazily if needed and thus simplify.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good instinct — the Callable wasn't needed. I've reworked it so the ZK host is resolved once per entry point (skipped with --update-include-file-only) and passed as a plain nullable String zkHost inside the AuthParams record; the existing null checks report errors exactly where they did before.

I also rewrote the branch into two commits: a pure parser-independent refactor of AuthTool (no picocli), and the picocli layer on top. The refactor commit is up as its own PR against main: #4688 — it can land there independently of this branch.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

thanks for this... In some code bases Callables are everywhere, and it makes sense and you grok it, but in ours, we don't really do that...

janhoy added 2 commits July 31, 2026 03:10
…methods

Restructures the monolithic handleBasicAuth(cli) into an AuthParams record
and cli-free handleCommand()/enableBasicAuth()/disableBasicAuth()/
clearSecurityJson() methods. The ZooKeeper connection string is resolved
once in runImpl (skipped with --update-include-file-only) and passed as a
plain nullable String; error reporting stays at the existing check sites.
No functional change intended.
Adds the picocli annotation, option fields and callTool() to AuthTool,
building the same AuthParams and calling the same handleCommand() as the
commons-cli path. Includes AuthToolPicocliTest running the inherited
AuthToolTest suite through picocli, and ref-guide docs for bin/solr auth.
@janhoy
janhoy force-pushed the jira/SOLR-17697-picocli-auth branch from a0bab52 to 0e3d509 Compare July 31, 2026 01:14
@janhoy janhoy changed the title SOLR-17697: Implement picocli for auth command SOLR-17697: Implement picocli for auth command / AuthTool Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cat:cli documentation Improvements or additions to documentation tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants