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

Commit a23ce6f

Browse files
committed
*: Prevented unit's Contents modification
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.
1 parent bbea486 commit a23ce6f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

job/job.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,14 @@ func (j *Job) requirements() map[string][]string {
175175
}
176176

177177
if uni != nil {
178+
processedValues := make([]string, len(values))
178179
for i, v := range values {
179-
values[i] = unitPrintf(v, *uni)
180+
processedValues[i] = unitPrintf(v, *uni)
180181
}
182+
requirements[key] = processedValues
183+
} else {
184+
requirements[key] = values
181185
}
182-
requirements[key] = values
183186
}
184187

185188
return requirements

0 commit comments

Comments
 (0)