Background
Helm 3.14 added -l, --labels stringToString on helm install and helm upgrade. Labels are attached to the release record (and copied onto the Secret/ConfigMap storing release state), useful for filtering and for org/billing tagging.
Helm SDK exposes this as (*action.Install).Labels map[string]string and (*action.Upgrade).Labels map[string]string (install.go:101).
Acceptance criteria
Proposed Java API
helm.install()
.withName("r")
.withLabel("env", "prod")
.withLabel("team", "platform")
.withKubeConfig(kc)
.call();
Implementation guide
The codebase already passes Map<String,String> over JNA as a URL-encoded string. Copy this pattern for labels — see how Values flows.
Java side (InstallCommand.java, UpgradeCommand.java)
- Add
private final Map<String,String> labels = new LinkedHashMap<>(); field.
- Add
withLabel(String key, String value) (append into the map; return this).
- In
call(), pass urlEncode(labels) as the new labels argument (helper already exists in HelmCommand).
JNA (InstallOptions.java, UpgradeOptions.java)
- Add
public String labels; field; update @Structure.FieldOrder (append at the end) and the constructor signature.
CGO bridge (native/main.go)
- Add
char* labels; to struct InstallOptions and struct UpgradeOptions. The field order must match the Java @Structure.FieldOrder exactly.
- Pass through:
Labels: C.GoString(options.labels).
Go (native/internal/helm/install.go, upgrade.go)
- Add
Labels string field to the Go options struct (URL-encoded; decoded inside Install/Upgrade).
- Decode with
url.ParseQuery(options.Labels) (same pattern as mergeValues in install.go:289 for Values).
- Convert
url.Values → map[string]string (take the first value per key).
- Set
client.Labels = ....
Tests
- Add to
HelmKubernetesTest.Install and HelmKubernetesTest.Upgrade nested classes. Labels persist in the release Secret, so client-only mode won't exercise them — needs the real KinD container.
- Scenarios:
- Install with a single label — no exception, release lands as
deployed
- Install with multiple labels — same
- Upgrade adding a label to a release that had none — succeeds
- Optionally: fetch the release Secret with the Fabric8 / k8s client (already on the test classpath via Testcontainers/KinD) and assert the
metadata.labels block contains the expected entries. If too heavy, omit and trust the SDK.
Contributor checklist
References
Background
Helm 3.14 added
-l, --labels stringToStringonhelm installandhelm upgrade. Labels are attached to the release record (and copied onto the Secret/ConfigMap storing release state), useful for filtering and for org/billing tagging.Helm SDK exposes this as
(*action.Install).Labels map[string]stringand(*action.Upgrade).Labels map[string]string(install.go:101).Acceptance criteria
InstallCommand.withLabel(String key, String value)adds a single label; multiple calls accumulateUpgradeCommand(helm 3.14+ supports it there too)Proposed Java API
Implementation guide
The codebase already passes
Map<String,String>over JNA as a URL-encoded string. Copy this pattern for labels — see howValuesflows.Java side (
InstallCommand.java,UpgradeCommand.java)private final Map<String,String> labels = new LinkedHashMap<>();field.withLabel(String key, String value)(append into the map; returnthis).call(), passurlEncode(labels)as the newlabelsargument (helper already exists inHelmCommand).JNA (
InstallOptions.java,UpgradeOptions.java)public String labels;field; update@Structure.FieldOrder(append at the end) and the constructor signature.CGO bridge (
native/main.go)char* labels;tostruct InstallOptionsandstruct UpgradeOptions. The field order must match the Java@Structure.FieldOrderexactly.Labels: C.GoString(options.labels).Go (
native/internal/helm/install.go,upgrade.go)Labels stringfield to the Go options struct (URL-encoded; decoded insideInstall/Upgrade).url.ParseQuery(options.Labels)(same pattern asmergeValuesininstall.go:289forValues).url.Values→map[string]string(take the first value per key).client.Labels = ....Tests
HelmKubernetesTest.InstallandHelmKubernetesTest.Upgradenested classes. Labels persist in the release Secret, so client-only mode won't exercise them — needs the real KinD container.deployedmetadata.labelsblock contains the expected entries. If too heavy, omit and trust the SDK.Contributor checklist
@authorJavadoc tagmake build-native && ./mvnw test -pl helm-java -Dtest=HelmKubernetesTestgreenReferences
Valuesis URL-encoded across JNA —InstallCommand.java:106+install.go:289(url.ParseQuery)