[lxc-devel] [distrobuilder/master] generator: Also prepend host entry on LXD
stgraber on Github
lxc-bot at linuxcontainers.org
Wed Mar 14 18:54:11 UTC 2018
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 362 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180314/e982fd88/attachment.bin>
-------------- next part --------------
From 4985f88024d8334277a6c6f86b60f3c028074ef8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Wed, 14 Mar 2018 14:52:33 -0400
Subject: [PATCH] generator: Also prepend host entry on LXD
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
generators/hosts.go | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/generators/hosts.go b/generators/hosts.go
index 7d5d26e..458e233 100644
--- a/generators/hosts.go
+++ b/generators/hosts.go
@@ -80,6 +80,11 @@ func (g HostsGenerator) RunLXD(cacheDir, sourceDir string, img *image.LXDImage,
// Replace hostname with placeholder
content = []byte(strings.Replace(string(content), "distrobuilder", "{{ container.name }}", -1))
+ // Add a new line if needed
+ if !strings.Contains(string(content), "{{ container.name }}") {
+ content = append([]byte("127.0.1.1\t{{ container.name }}\n"), content...)
+ }
+
// Write the template
err = ioutil.WriteFile(filepath.Join(templateDir, "hosts.tpl"), content, 0644)
if err != nil {
More information about the lxc-devel
mailing list