Skip to content

Commit

Permalink
alway load all templates
Browse files Browse the repository at this point in the history
  • Loading branch information
dadgar committed Nov 10, 2017
1 parent d93ecb9 commit da852ea
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
6 changes: 3 additions & 3 deletions client/consul_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func (tm *TaskTemplateManager) run() {
tm.config.Hooks.Kill(consulTemplateSourceName, err.Error(), true)
return
}
tm.config.EnvBuilder.MergeTemplateEnv(envMap)
tm.config.EnvBuilder.SetTemplateEnv(envMap)

// Unblock the task
tm.config.Hooks.UnblockStart(consulTemplateSourceName)
Expand Down Expand Up @@ -389,12 +389,12 @@ func (tm *TaskTemplateManager) handleTemplateRerenders(allRenderedTime time.Time
}

// Read environment variables from templates
envMap, err := loadTemplateEnv(tmpls, tm.config.TaskDir)
envMap, err := loadTemplateEnv(tm.config.Templates, tm.config.TaskDir)
if err != nil {
tm.config.Hooks.Kill(consulTemplateSourceName, err.Error(), true)
return
}
tm.config.EnvBuilder.MergeTemplateEnv(envMap)
tm.config.EnvBuilder.SetTemplateEnv(envMap)

for _, tmpl := range tmpls {
switch tmpl.ChangeMode {
Expand Down
12 changes: 2 additions & 10 deletions client/driver/env/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -532,17 +532,9 @@ func (b *Builder) SetHostEnvvars(filter []string) *Builder {
return b
}

// MergeTemplateEnv is used to merge the passed environment variables with
// existing environment variables set from a template.
func (b *Builder) MergeTemplateEnv(m map[string]string) *Builder {
func (b *Builder) SetTemplateEnv(m map[string]string) *Builder {
b.mu.Lock()
if b.templateEnv == nil {
b.templateEnv = m
} else {
for k, v := range m {
b.templateEnv[k] = v
}
}
b.templateEnv = m
b.mu.Unlock()
return b
}
Expand Down

0 comments on commit da852ea

Please sign in to comment.