Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
*: Prevented unit's Contents modification
Browse files Browse the repository at this point in the history
Resolves #1514

The problem was caused by the [code optimization](#1376). Before that each unit was stored in its own variable. Then this code was optimized and units became stored in hash map (`getAllUnitsHashMap`). Each hash was assigned to the unit's pointer. And when template unit was checked by `requirements()` function, its content was modified by `values[i] = unitPrintf(v, *uni)` code. Once templated unit was modified, all related units (which have same hash) were modified too, because they are related to one pointer.
  • Loading branch information
kayrus committed Mar 30, 2016
1 parent bbea486 commit a23ce6f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions job/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,14 @@ func (j *Job) requirements() map[string][]string {
}

if uni != nil {
processedValues := make([]string, len(values))
for i, v := range values {
values[i] = unitPrintf(v, *uni)
processedValues[i] = unitPrintf(v, *uni)
}
requirements[key] = processedValues
} else {
requirements[key] = values
}
requirements[key] = values
}

return requirements
Expand Down

0 comments on commit a23ce6f

Please sign in to comment.