Repository navigation
feat: support --labels on helm install and helm upgrade #277
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 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
-
InstallCommand.withLabel(String key, String value)adds a single label; multiple calls accumulate - Same on
UpgradeCommand(helm 3.14+ supports it there too) - Labels reach the underlying helm Release record (verifiable in the storage Secret)
- Integration test confirms install/upgrade succeeds with labels and surfaces no errors
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; returnthis). - In
call(), passurlEncode(labels)as the newlabelsargument (helper already exists inHelmCommand).
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;tostruct InstallOptionsandstruct UpgradeOptions. The field order must match the Java@Structure.FieldOrderexactly. - Pass through:
Labels: C.GoString(options.labels).
Go (native/internal/helm/install.go, upgrade.go)
- Add
Labels stringfield to the Go options struct (URL-encoded; decoded insideInstall/Upgrade). - Decode with
url.ParseQuery(options.Labels)(same pattern asmergeValuesininstall.go:289forValues). - Convert
url.Values→map[string]string(take the first value per key). - Set
client.Labels = ....
Tests
- Add to
HelmKubernetesTest.InstallandHelmKubernetesTest.Upgradenested 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
- Install with a single label — no exception, release lands as
- Optionally: fetch the release Secret with the Fabric8 / k8s client (already on the test classpath via Testcontainers/KinD) and assert the
metadata.labelsblock contains the expected entries. If too heavy, omit and trust the SDK.
Contributor checklist
- Java 8 syntax only
- Apache 2.0 header
-
@authorJavadoc tag - DCO sign-off
-
make build-native && ./mvnw test -pl helm-java -Dtest=HelmKubernetesTestgreen
References
- Helm CLI install: https://helm.sh/docs/helm/helm_install/
- Helm CLI upgrade: https://helm.sh/docs/helm/helm_upgrade/
- Helm 3.14 release notes: https://github.com/helm/helm/releases/tag/v3.14.0
- Project workflow: AGENTS.md → Adding a new Helm command
- Pattern to copy: how
Valuesis URL-encoded across JNA —InstallCommand.java:106+install.go:289(url.ParseQuery)
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
feat: add labels option to install command (manusa#277)
feat: add labels option to install command (manusa#277)
feat: add labels option to install command (manusa#277)
[-]Feature Request: Support --labels option in helm install to allow adding custom labels[/-][+]feat: support `--labels` on `helm install` and `helm upgrade`[/+]