The iteration variables of for range loop are re-used each iteration. It is the same variable and it is re-assigned each iteration, therefore the multiple elements of the deploymentsInNamespace slice referring to the same Deployment object.
The one-liner d := deployment fix the problem because the redeclaration creates a new variable each iteration and has the value of iteration variable.
The iteration variables of for range loop are re-used each iteration. It is the same variable and it is re-assigned each iteration, therefore the multiple elements of the deploymentsInNamespace slice referring to the same Deployment object. The one-liner
d := deployment
fix the problem because the redeclaration creates a new variable each iteration and has the value of iteration variable.