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
Implementation guide
Tiny change once the semantic decision lands.
Go (native/internal/helm/search.go)
- Add
Versions bool to SearchOptions.
- Change
searchIndex.AddRepo(name, index, true) → searchIndex.AddRepo(name, index, options.Versions).
CGO bridge (native/main.go)
- Add
int versions; to struct SearchOptions. Pass through.
JNA (SearchOptions.java)
- Add
public int versions;. Update @Structure.FieldOrder and the constructor.
Java (SearchRepoCommand.java)
- Add the chosen builder method (
versions() or latestOnly()); set the int flag with toInt(true).
Tests
- Location: existing
helm-java/src/test/java/com/marcnuri/helm/HelmSearchTest.java.
- The current
withDefaults test uses https://charts.helm.sh/stable which 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
References
Background
Helm CLI's
helm search reporeturns one row per chart by default (latest version matching the version constraint), and all matching versions when-l, --versionsis passed.helm-java's current behavior is the opposite.
native/internal/helm/search.go:72callssearchIndex.AddRepo(name, index, true)unconditionally — so the index always keeps every version and the output always includes all of them. helm CLI passesall = (--versions || --version set)(search_repo.go:197) —all=falsecauses 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:
.versions()to opt into all. Breaking change for existing callers who rely on receiving all versions..latestOnly()to opt out. Diverges from helm CLI.Acceptance criteria
searchIndex.AddRepo(name, index, allVersions)receives the flag fromSearchOptionsHelmSearchTestcovers both modes against a real repo with multi-version chartsImplementation guide
Tiny change once the semantic decision lands.
Go (
native/internal/helm/search.go)Versions booltoSearchOptions.searchIndex.AddRepo(name, index, true)→searchIndex.AddRepo(name, index, options.Versions).CGO bridge (
native/main.go)int versions;tostruct SearchOptions. Pass through.JNA (
SearchOptions.java)public int versions;. Update@Structure.FieldOrderand the constructor.Java (
SearchRepoCommand.java)versions()orlatestOnly()); set the int flag withtoInt(true).Tests
helm-java/src/test/java/com/marcnuri/helm/HelmSearchTest.java.withDefaultstest useshttps://charts.helm.sh/stablewhich has many versions per chart.Contributor checklist
@authorJavadoc tagmake build-native && ./mvnw test -pl helm-java -Dtest=HelmSearchTestgreenReferences
search_repo.go:161-201