Skip to content

Commit bcafe99

Browse files
authored
Have one and only one \n character at the end of the system-probe.yaml (#49885)
Recent change corrected the missing tailing \n in the system-probe.yaml and another removed it by mistake. This missing \n shouldn't have execution impact since it doesn't prevent the yaml parsing. However, this caused the agent_linux_install_script’s unit test to fail, as the script checks for the configuration by ensuring it is POSIX-compliant which expect a tailing \n Co-authored-by: stanislas.plowiecki <stanislas.plowiecki@datadoghq.com>
1 parent 15b1c1c commit bcafe99

2 files changed

Lines changed: 6 additions & 9 deletions

File tree

pkg/config/render_config/render_config.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,20 +113,17 @@ func mkContext(buildType string, osName string) context {
113113
}
114114

115115
func render(destFile string, tplFile string, component string, osName string) {
116-
f, err := os.Create(destFile)
117-
if err != nil {
118-
panic(err)
119-
}
120-
121116
tplFilename := filepath.Base(tplFile)
122117

123118
t := template.Must(template.New(tplFilename).ParseFiles(tplFile))
124-
err = t.Execute(f, mkContext(component, osName))
125-
if err != nil {
119+
var buf bytes.Buffer
120+
if err := t.Execute(&buf, mkContext(component, osName)); err != nil {
126121
panic(err)
127122
}
128123

129-
if err := f.Close(); err != nil {
124+
rendered := append(bytes.TrimRight(buf.Bytes(), "\n\r \t"), '\n')
125+
126+
if err := os.WriteFile(destFile, rendered, 0644); err != nil {
130127
panic(err)
131128
}
132129
}

tasks/schema/template.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ def generate_template(schema_file, dest, build_type, os_target):
392392

393393
final_render = [line.strip() for line in config_template.strip().split("\n")]
394394
with open(dest, "w") as f:
395-
f.write("\n".join(final_render))
395+
f.write("\n".join(final_render) + "\n")
396396

397397

398398
@task(

0 commit comments

Comments
 (0)