[lxc-devel] [distrobuilder/master] generators: Append empty line to template files

monstermunchkin on Github lxc-bot at linuxcontainers.org
Thu Jun 28 16:20:33 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 364 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180628/e967085e/attachment.bin>
-------------- next part --------------
From 1feafdc198af2738d6f2af5db631bd168180282a Mon Sep 17 00:00:00 2001
From: Thomas Hipp <thomas.hipp at canonical.com>
Date: Thu, 28 Jun 2018 18:19:38 +0200
Subject: [PATCH] generators: Append empty line to template files

Signed-off-by: Thomas Hipp <thomas.hipp at canonical.com>
---
 generators/template.go | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/generators/template.go b/generators/template.go
index a125274..7470156 100644
--- a/generators/template.go
+++ b/generators/template.go
@@ -4,6 +4,7 @@ import (
 	"fmt"
 	"os"
 	"path/filepath"
+	"strings"
 
 	"github.com/lxc/lxd/shared/api"
 
@@ -39,6 +40,11 @@ func (g TemplateGenerator) RunLXD(cacheDir, sourceDir string, img *image.LXDImag
 
 	defer file.Close()
 
+	// Append final new line if missing
+	if !strings.HasSuffix(defFile.Content, "\n") {
+		defFile.Content += "\n"
+	}
+
 	_, err = file.WriteString(defFile.Content)
 	if err != nil {
 		return fmt.Errorf("Failed to write to content to %s template: %s", defFile.Name, err)


More information about the lxc-devel mailing list