feat(validator): replace helm CLI subprocess with Helm Go SDK for chart rendering#186
Merged
mchmarny merged 4 commits intoNVIDIA:mainfrom Feb 23, 2026
Merged
feat(validator): replace helm CLI subprocess with Helm Go SDK for chart rendering#186mchmarny merged 4 commits intoNVIDIA:mainfrom
mchmarny merged 4 commits intoNVIDIA:mainfrom
Conversation
mchmarny
reviewed
Feb 23, 2026
Member
mchmarny
left a comment
There was a problem hiding this comment.
Clean refactoring — the motivation (distroless/Ko compatibility) is solid and the implementation follows project patterns well. The behavioral equivalence table in the description is thorough.
One item to fix before merge: the downloaded chart archive from locateChart() is never cleaned up, which leaks temp files in the long-running API server path. See inline comment on lines 186-189.
The remaining comments are non-blocking nits and suggestions (context cancellation gap in LocateChart, credential options, error code precision, test coverage for the new SDK path).
xdu31
commented
Feb 23, 2026
…ls, error codes, SDK tests
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace the
helm templateCLI subprocess with the Helm Go SDK (helm.sh/helm/v3) for chart rendering in the validator's expected resource auto-discovery. This eliminates the external binary dependency, enabling the validator to run in distroless/Ko images without a helm binary or shell.Motivation / Context
The validator auto-discovers expected workload resources (Deployments, DaemonSets, StatefulSets) from Helm charts using
helm template. The previous implementation shelled out to the helm CLI as a subprocess, which required:-fflagThe Helm Go SDK provides the same rendering capability as a library call, removing all three requirements. This is critical for the API server path (built with Ko/distroless) and simplifies the credential story — the SDK honors
HELM_REGISTRY_CONFIGidentically to the CLI.Follows up on PR #164 which introduced the two-phase discovery.
Type of Change
Component(s) Affected
cmd/aicr,pkg/cli)cmd/aicrd,pkg/api,pkg/server)pkg/recipe)pkg/bundler,pkg/component/*)pkg/collector,pkg/snapshotter)pkg/validator)pkg/errors,pkg/k8s)docs/,examples/)Implementation Notes
Modified:
pkg/validator/resource_discovery.goRemoved:
helmCommandconstant andexec.LookPathpre-check for helm binaryexecuteSubprocess()— generic CLI runner viaexec.CommandContextwriteValuesToTempFile()— marshal values to temp YAML file for-fflagos,os/exec,stderrorsimportsAdded:
helm.sh/helm/v3/pkg/action,chart/loader,cli,registryrenderHelmTemplate()rewritten using SDK:registry.NewClient()for OCI auth (honorsHELM_REGISTRY_CONFIG)action.NewInstallwithDryRun: true,ClientOnly: true(no cluster connection)install.RunWithContext(ctx, chart, values)— values passed as Go map directlylocateChart()— resolves chart reference viainstall.LocateChart()for both OCI and HTTP reposChanged:
resolveExpectedResources()— removedneedsHelm/exec.LookPathpre-check, addedctx.Err()check in the component loop so context cancellation propagates as a hard errorModified:
pkg/validator/resource_discovery_test.goTestWriteValuesToTempFile(temp file no longer used)TestResolveExpectedResources_ErrorOnMissingCLI(no CLI binary to check)Modified:
go.modhelm.sh/helm/v3 v3.20.0as direct dependencyBehavioral Changes
-fflagHELM_REGISTRY_CONFIGvia helm CLIregistry.NewClient()helm template --repo/ OCIinstall.LocateChart()ctx.Err()Testing
Risk Assessment
Rollout notes: Pure refactoring — the SDK produces identical rendered output to the CLI subprocess. The credential mechanism (
HELM_REGISTRY_CONFIG) is unchanged. The only behavioral difference is that context cancellation is now checked per-component in the discovery loop.Checklist
make testwith-race)make lint)git commit -S) — GPG signing info