mirror of
https://github.com/davidallendj/configurator.git
synced 2025-12-20 11:37:00 -07:00
generator: fixed issue with templates not being generated
This commit is contained in:
parent
4f836630b0
commit
88d365155f
3 changed files with 19 additions and 5 deletions
|
|
@ -163,7 +163,7 @@ func LoadPlugins(dirpath string, opts ...Option) (map[string]Generator, error) {
|
|||
// be used. This function will only load the plugin on-demand and fetch resources as needed.
|
||||
//
|
||||
// This function requires that a target and plugin path be set at minimum.
|
||||
func Generate(plugin string, params Params) (FileMap, error) {
|
||||
func Generate(config *config.Config, plugin string, params Params) (FileMap, error) {
|
||||
var (
|
||||
gen Generator
|
||||
ok bool
|
||||
|
|
@ -182,7 +182,7 @@ func Generate(plugin string, params Params) (FileMap, error) {
|
|||
}
|
||||
}
|
||||
|
||||
return gen.Generate(nil, params)
|
||||
return gen.Generate(config, params)
|
||||
}
|
||||
|
||||
// Main function to generate a collection of files as a map with the path as the key and
|
||||
|
|
@ -232,6 +232,11 @@ func GenerateWithTarget(config *config.Config, target string) (FileMap, error) {
|
|||
}
|
||||
}
|
||||
|
||||
// check if there's at least one template available
|
||||
if len(targetInfo.TemplatePaths) <= 0 {
|
||||
return nil, fmt.Errorf("expects at least one template to be available")
|
||||
}
|
||||
|
||||
// prepare params to pass into generator
|
||||
params.Templates = map[string]Template{}
|
||||
for _, templatePath := range targetInfo.TemplatePaths {
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import (
|
|||
"github.com/OpenCHAMI/configurator/pkg/util"
|
||||
"github.com/nikolalohinski/gonja/v2"
|
||||
"github.com/nikolalohinski/gonja/v2/exec"
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
type Template struct {
|
||||
|
|
@ -65,6 +66,8 @@ func ApplyTemplates(mappings Mappings, templates map[string]Template) (FileMap,
|
|||
outputs[path] = b.Bytes()
|
||||
}
|
||||
|
||||
log.Debug().Any("templates", templates).Any("outputs", outputs).Any("mappings", mappings).Msg("apply templates")
|
||||
|
||||
return outputs, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue