diff --git a/pkg/templater/services.go b/pkg/templater/services.go index cfdd248..b95779d 100644 --- a/pkg/templater/services.go +++ b/pkg/templater/services.go @@ -69,7 +69,7 @@ func (s *Service) Manage(templateDir string, rootDir string) error { } log.Print(" Generating configuration files\n") - err = processConfigFiles(s.ConfigFiles, s.Vars, templateDir, rootDir) + err = processConfigFiles(s, templateDir, rootDir) if err != nil { return fmt.Errorf("ProcessingTemplatesFailed with error: %v", err) } @@ -84,14 +84,14 @@ func (s *Service) Manage(templateDir string, rootDir string) error { return nil } -func processConfigFiles(tpls []ConfigFile, variables map[string]interface{}, templateDir string, rootDir string) error { - values, err := json.Marshal(variables) +func processConfigFiles(s *Service, templateDir string, rootDir string) error { + values, err := json.Marshal(s) if err != nil { return fmt.Errorf("Error unmarshaling values on template process; %v", err) } var servicesToRestart []string - for _, tpl := range tpls { + for _, tpl := range s.ConfigFiles { fileExt := filepath.Ext(tpl.Source) if fileExt == ".hcl" { tpl.TemplateType = "hcl" @@ -100,7 +100,7 @@ func processConfigFiles(tpls []ConfigFile, variables map[string]interface{}, tem } else { return fmt.Errorf("Unsupported file type %s, templates extensions have to be '.hcl' or '.tpl'", fileExt) } - if err := tpl.Generate("/tmp/test", templateDir, values); err != nil { + if err := tpl.Generate(rootDir, templateDir, values); err != nil { return fmt.Errorf("Template %s generation failed with error %v", tpl.Source, err) }