From 2dcce314fe17e17ff37e601cffcb93504391f814 Mon Sep 17 00:00:00 2001 From: Stanislas Date: Fri, 24 Apr 2026 17:35:58 +0200 Subject: [PATCH 1/2] Have one and only one newline character at the end of the system-probe.yaml configuration --- pkg/config/system-probe_template.yaml | 4 +--- tasks/schema/template.py | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/pkg/config/system-probe_template.yaml b/pkg/config/system-probe_template.yaml index ba5826632fe7..597b6531fc69 100644 --- a/pkg/config/system-probe_template.yaml +++ b/pkg/config/system-probe_template.yaml @@ -236,9 +236,7 @@ # # Set to true to activate the CWS network detections. # # enabled: true - -{{- if (eq .OS "windows") }} - +{{ if (eq .OS "windows") }} ################################################## ## Datadog Agent Windows Crash Detection module ## ################################################## diff --git a/tasks/schema/template.py b/tasks/schema/template.py index 40cafb635f36..219efb722d57 100644 --- a/tasks/schema/template.py +++ b/tasks/schema/template.py @@ -413,7 +413,7 @@ def generate_template(schema_file, dest, build_type, os_target): final_render = [line.strip() for line in config_template.strip().split("\n")] with open(dest, "w") as f: - f.write("\n".join(final_render)) + f.write("\n".join(final_render) + "\n") @task( From 90a4688bd20dd7ce5c6faa62654a5a42ed585467 Mon Sep 17 00:00:00 2001 From: Stanislas Date: Mon, 27 Apr 2026 09:34:47 +0200 Subject: [PATCH 2/2] correct test --- pkg/config/render_config/render_config.go | 13 +++++-------- pkg/config/system-probe_template.yaml | 4 +++- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/pkg/config/render_config/render_config.go b/pkg/config/render_config/render_config.go index 5dd5108684f4..59ef4eb195cc 100644 --- a/pkg/config/render_config/render_config.go +++ b/pkg/config/render_config/render_config.go @@ -113,20 +113,17 @@ func mkContext(buildType string, osName string) context { } func render(destFile string, tplFile string, component string, osName string) { - f, err := os.Create(destFile) - if err != nil { - panic(err) - } - tplFilename := filepath.Base(tplFile) t := template.Must(template.New(tplFilename).ParseFiles(tplFile)) - err = t.Execute(f, mkContext(component, osName)) - if err != nil { + var buf bytes.Buffer + if err := t.Execute(&buf, mkContext(component, osName)); err != nil { panic(err) } - if err := f.Close(); err != nil { + rendered := append(bytes.TrimRight(buf.Bytes(), "\n\r \t"), '\n') + + if err := os.WriteFile(destFile, rendered, 0644); err != nil { panic(err) } } diff --git a/pkg/config/system-probe_template.yaml b/pkg/config/system-probe_template.yaml index 597b6531fc69..ba5826632fe7 100644 --- a/pkg/config/system-probe_template.yaml +++ b/pkg/config/system-probe_template.yaml @@ -236,7 +236,9 @@ # # Set to true to activate the CWS network detections. # # enabled: true -{{ if (eq .OS "windows") }} + +{{- if (eq .OS "windows") }} + ################################################## ## Datadog Agent Windows Crash Detection module ## ##################################################