Skip to content

Commit

Permalink
Remove bad loop over all templates pulling in all variables into the …
Browse files Browse the repository at this point in the history
…role.

Also test for existence in the per-role templates, these contain the globals too
(See calculateRoleConfigurationTemplates). This also fixes a mismatch vs the test code.
  • Loading branch information
andreas-kupries committed Apr 20, 2017
1 parent 81d9202 commit fc6aa9c
Showing 1 changed file with 1 addition and 18 deletions.
19 changes: 1 addition & 18 deletions model/mustache.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ func (r *Role) GetVariablesForRole() (ConfigurationVariableSlice, error) {
for _, property := range job.Properties {
propertyName := fmt.Sprintf("properties.%s", property.Name)

if template, ok := r.rolesManifest.Configuration.Templates[propertyName]; ok {

if template, ok := r.Configuration.Templates[propertyName]; ok {
varsInTemplate, err := parseTemplate(template)
if err != nil {
return nil, err
Expand All @@ -47,22 +46,6 @@ func (r *Role) GetVariablesForRole() (ConfigurationVariableSlice, error) {
}
}

// TODO we might want to exclude env vars that are from templates that are
// overwritten by per-role configs
for _, template := range r.Configuration.Templates {
varsInTemplate, err := parseTemplate(template)

if err != nil {
return nil, err
}

for _, envVar := range varsInTemplate {
if confVar, ok := configsDictionary[envVar]; ok {
configs[confVar.Name] = confVar
}
}
}

result := make(ConfigurationVariableSlice, 0, len(configs))

for _, value := range configs {
Expand Down

0 comments on commit fc6aa9c

Please sign in to comment.