generator: Also prepend host entry on LXD

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
This commit is contained in:
Stéphane Graber 2018-03-14 14:52:33 -04:00
parent 130054cb31
commit 4985f88024
No known key found for this signature in database
GPG Key ID: C638974D64792D67

View File

@ -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 {