Repository navigation
feat: control all-versions vs latest-only on helm search repo (currently always returns all) #279
Copy link
Copy link
Open
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is needed
Description
Background
Helm CLI's helm search repo returns one row per chart by default (latest version matching the version constraint), and all matching versions when -l, --versions is passed.
helm-java's current behavior is the opposite. native/internal/helm/search.go:72 calls searchIndex.AddRepo(name, index, true) unconditionally — so the index always keeps every version and the output always includes all of them. helm CLI passes all = (--versions || --version set) (search_repo.go:197) — all=false causes the index to retain only the latest per chart.
This issue tracks adding control over the toggle in the Java API.
Decision needed before implementing
Two options for the maintainer — please pick one in this thread:
- (a) Match helm CLI semantics — default to latest-only; add
.versions()to opt into all. Breaking change for existing callers who rely on receiving all versions. - (b) Non-breaking — keep current "all versions" as default; add
.latestOnly()to opt out. Diverges from helm CLI.
Acceptance criteria
- Java API exposes a way to toggle between latest-only and all-versions
- Method name reflects the chosen semantic (above)
-
searchIndex.AddRepo(name, index, allVersions)receives the flag fromSearchOptions -
HelmSearchTestcovers both modes against a real repo with multi-version charts
Implementation guide
Tiny change once the semantic decision lands.
Go (native/internal/helm/search.go)
- Add
Versions booltoSearchOptions. - Change
searchIndex.AddRepo(name, index, true)→searchIndex.AddRepo(name, index, options.Versions).
CGO bridge (native/main.go)
- Add
int versions;tostruct SearchOptions. Pass through.
JNA (SearchOptions.java)
- Add
public int versions;. Update@Structure.FieldOrderand the constructor.
Java (SearchRepoCommand.java)
- Add the chosen builder method (
versions()orlatestOnly()); set the int flag withtoInt(true).
Tests
- Location: existing
helm-java/src/test/java/com/marcnuri/helm/HelmSearchTest.java. - The current
withDefaultstest useshttps://charts.helm.sh/stablewhich has many versions per chart. - Add: a test asserting result size differs between latest-only and all-versions modes for the same query, e.g.:
final int latestOnly = Helm.search().repo()./* latest mode */.call().size(); final int allVersions = Helm.search().repo()./* all-versions mode */.call().size(); assertThat(allVersions).isGreaterThan(latestOnly);
Contributor checklist
- Java 8 syntax only
- Apache 2.0 header
-
@authorJavadoc tag - DCO sign-off
-
make build-native && ./mvnw test -pl helm-java -Dtest=HelmSearchTestgreen
References
- Helm CLI: https://helm.sh/docs/helm/helm_search_repo/
- helm CLI behavior:
search_repo.go:161-201 - Project workflow: AGENTS.md → Adding a new Helm command
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is needed
Activity
[-]Add `--versions` flag to `helm search repo` command[/-][+]feat: control all-versions vs latest-only on `helm search repo` (currently always returns all)[/+]