mirror of
https://github.com/davidallendj/configurator.git
synced 2025-12-20 03:27:02 -07:00
fix: added check to loadTargets() to prevent panic
This commit is contained in:
parent
235efcdd07
commit
2edd8367bc
1 changed files with 6 additions and 0 deletions
|
|
@ -186,11 +186,17 @@ func (s *Server) Generate(opts ...client.Option) func(w http.ResponseWriter, r *
|
|||
}
|
||||
|
||||
func (s *Server) loadTargets() {
|
||||
// make sure the map is initialized first
|
||||
if s.Targets == nil {
|
||||
s.Targets = make(map[string]Target)
|
||||
}
|
||||
// add targets from config to server
|
||||
for name, target := range s.Config.Targets {
|
||||
serverTarget := Target{
|
||||
Name: name,
|
||||
PluginPath: target.Plugin,
|
||||
}
|
||||
// add templates using template paths from config
|
||||
for _, templatePath := range target.TemplatePaths {
|
||||
template := generator.Template{}
|
||||
template.LoadFromFile(templatePath)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue