Background
helm template --output-dir <dir> writes each rendered manifest to a separate file under <dir> instead of concatenating to stdout. With --use-release-name, files go under <dir>/<release-name>/. Common use: GitOps workflows that commit rendered manifests to a repo.
Helm SDK exposes this as (*action.Install).OutputDir (install.go:93) — template internally uses an Install action with ClientOnly=true.
Acceptance criteria
Proposed Java API
helm.template()
.withOutputDir(Paths.get("/tmp/rendered"))
.useReleaseName()
.call();
// → files like /tmp/rendered/release-name/templates/deployment.yaml
Implementation guide
Reference impl to copy patterns from: existing TemplateCommand + template.go (which delegates to install(...) internally).
Go (native/internal/helm/install.go + template.go)
- Add
OutputDir string and UseReleaseName bool to InstallOptions struct (internal Go type). Only template will set these; install ignores them — that's fine.
- In
install(...), set client.OutputDir = options.OutputDir and client.UseReleaseName = options.UseReleaseName.
- In
template.go, plumb the new fields from TemplateOptions → the internal InstallOptions call.
CGO bridge (native/main.go)
- Add
char* outputDir; and int useReleaseName; to struct TemplateOptions. Field order must match the JNA struct.
- Pass through to
helm.TemplateOptions{OutputDir, UseReleaseName}.
JNA + Java
- Add
public String outputDir; public int useReleaseName; to lib/api/.../TemplateOptions.java. Update @Structure.FieldOrder and constructor.
- Add
withOutputDir(Path) and useReleaseName() builders to TemplateCommand.
Tests
- Add to
HelmTemplateTest.
- Use
@TempDir for the output dir.
- Scenarios:
withOutputDir: after .call(), assert files exist (e.g. dir/templates/<chart-name>/...)
withOutputDir + useReleaseName: assert files are nested under <release-name>/
- No output dir: stdout return value still contains all manifests (existing behavior unchanged)
Contributor checklist
References
Background
helm template --output-dir <dir>writes each rendered manifest to a separate file under<dir>instead of concatenating to stdout. With--use-release-name, files go under<dir>/<release-name>/. Common use: GitOps workflows that commit rendered manifests to a repo.Helm SDK exposes this as
(*action.Install).OutputDir(install.go:93) — template internally uses an Install action withClientOnly=true.Acceptance criteria
TemplateCommand.withOutputDir(Path dir)writes each manifest to a separate file underdirTemplateCommand.useReleaseName()toggles the<dir>/<release-name>/nesting (matches helm CLI's--use-release-name)withOutputDir, current behavior is preserved (concatenated YAML returned as string)Proposed Java API
Implementation guide
Reference impl to copy patterns from: existing
TemplateCommand+template.go(which delegates toinstall(...)internally).Go (
native/internal/helm/install.go+template.go)OutputDir stringandUseReleaseName booltoInstallOptionsstruct (internal Go type). Only template will set these; install ignores them — that's fine.install(...), setclient.OutputDir = options.OutputDirandclient.UseReleaseName = options.UseReleaseName.template.go, plumb the new fields fromTemplateOptions→ the internalInstallOptionscall.CGO bridge (
native/main.go)char* outputDir;andint useReleaseName;tostruct TemplateOptions. Field order must match the JNA struct.helm.TemplateOptions{OutputDir, UseReleaseName}.JNA + Java
public String outputDir; public int useReleaseName;tolib/api/.../TemplateOptions.java. Update@Structure.FieldOrderand constructor.withOutputDir(Path)anduseReleaseName()builders toTemplateCommand.Tests
HelmTemplateTest.@TempDirfor the output dir.withOutputDir: after.call(), assert files exist (e.g.dir/templates/<chart-name>/...)withOutputDir + useReleaseName: assert files are nested under<release-name>/Contributor checklist
@authorJavadoc tagmake build-native && ./mvnw test -pl helm-java -Dtest=HelmTemplateTestgreenReferences
OutputDir)