[K3s] Emit LF line endings in generated helm/kubectl scripts (fixes Windows-only busybox syntax error) - #1551
Merged
aaronpowell merged 1 commit intoSep 1, 2026
Conversation
…ent syntax errors in busybox
Contributor
Author
|
@dotnet-policy-service agree |
aaronpowell
approved these changes
Sep 1, 2026
aaronpowell
enabled auto-merge (squash)
September 1, 2026 05:03
This was referenced Oct 1, 2026
Bump CommunityToolkit.Aspire.Hosting.Ollama from 13.6.0-beta.910 to 13.6.0
intochat/digitalbrain#113
Closed
Open
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.
Closes #1550
BuildHelmScriptandBuildManifestScriptcompose their scripts withStringBuilder.AppendLine, which appendsEnvironment.NewLine—\r\non Windows. Thescripts are injected into Linux containers and executed by busybox
ash, which does notstrip the trailing CR, so
if [ ... ]; thenis tokenized asthen\r. Theifis neverclosed and the script dies at EOF with
syntax error: unexpected end of file (expecting "then").This makes
AddHelmReleasefail 100% of the time on Windows hosts, andAddK8sManifestcarries the identical defect — it just escapes notice because the helm release fails first
in the sample AppHost. Both are fixed here.
Changes
K3sShellScript.AppendShellLine— appends a hard\n, with XML docs explainingthe busybox failure it exists to prevent.
K3sBuilderExtensions.Helm.cs— 12 call sites switched offAppendLine.K3sBuilderExtensions.Manifest.cs— 22 call sites switched offAppendLine.\r:BuildHelmScriptUsesLfLineEndingsOnly,BuildManifestScriptUsesLfLineEndingsOnly.I used a helper rather than normalizing the finished string with
sb.ToString().Replace("\r\n", "\n"), because the replace would also rewrite CRLF insidecaller-supplied data — a
WithHelmValuevalue, a repo URL, a release name — on its wayinto
helm --set. The helper only controls terminators the generator itself emits andleaves caller data byte-exact.
Not affected, for reviewers wondering why the cluster comes up healthy while the helm
container dies:
K3sInitEntrypointScriptis a C# raw string literal, and Roslynnormalizes line endings inside those to
\nregardless of the source file's endings.PR Checklist
Other information
The new regression tests fail on Windows without the fix and are trivially green on Linux —
which is correct, the invariant is the same on every host. Since CI runs on Linux, they
guard the intent rather than reproduce the failure there.
Verified on Windows 11 ARM64 / Docker 29.7.2 by running the actual generated scripts in
the real images against a live
rancher/k3s:v1.36.0-k3s1cluster:alpine/helm:3.18.0syntax error: unexpected end of file (expecting "then"), exit 2alpine/helm:3.18.0STATUS: deployed, exit 0 —podinfopod Runningalpine/kubectl:1.36.0configmap/app-config serverside-applied, exit 0alpine/kubectl:1.36.0Detected kustomization,configmap/monitoring-config serverside-applied, exit 0