From be0f1011c6823c85fe88bcacb9a1f05d41b4d100 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Sat, 12 Jan 2019 12:52:04 +0200 Subject: [PATCH] Allow dump generator to add LXC templates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber --- generators/dump.go | 11 ++++++++++- shared/definition.go | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/generators/dump.go b/generators/dump.go index a03aecb..43c0deb 100644 --- a/generators/dump.go +++ b/generators/dump.go @@ -15,7 +15,16 @@ type DumpGenerator struct{} // RunLXC dumps content to a file. func (g DumpGenerator) RunLXC(cacheDir, sourceDir string, img *image.LXCImage, defFile shared.DefinitionFile) error { - return g.Run(cacheDir, sourceDir, defFile) + err := g.Run(cacheDir, sourceDir, defFile) + if err != nil { + return err + } + + if defFile.Templated { + return img.AddTemplate(defFile.Path) + } + + return nil } // RunLXD dumps content to a file. diff --git a/shared/definition.go b/shared/definition.go index a6073ce..2333d02 100644 --- a/shared/definition.go +++ b/shared/definition.go @@ -96,6 +96,7 @@ type DefinitionFile struct { Releases []string `yaml:"releases,omitempty"` Name string `yaml:"name,omitempty"` Template DefinitionFileTemplate `yaml:"template,omitempty"` + Templated bool `yaml:"templated,omitempty"` } // A DefinitionFileTemplate represents the settings used by generators