Closed iocanel closed 7 years ago
Ah I've seen this issue before! Its always confused me too; rather than loading a Map of the ConfigMap resources, then looking up the one you want by name, I found just only setting a pointer to the one that matches the name fixes it.
e.g. like this loop https://github.com/funktionio/funktion/blob/master/cmd/logs.go#L99-L104
still no idea why loading a map of all values then looking up the map seems to always find the last one mind you!
@jstrachan: I am a complete noob at golang and I haven't touched c in ages, but I think that the problem is that you are storing the address of the resource (which is the iterator), like shown below:
p.configMaps[resource.Name] = &resource
The address, doesn't change, what changes is the value stored in the address. So all items within the map point to the same memory address.
This https://github.com/funktionio/funktion/blob/master/cmd/logs.go#L99-L104 also suffers from a similar problem, but break
saves the day.
I'll send a PR shortly.
@iocanel You got it! 50 points to you! http://www.g-var.com/posts/blog/go/50-shades-of-go/#iteration-variables-and-closures-in-for-statements
I am following the Getting Started Guide to the point where I edit the
twitter
connector.Then I derive from the script by trying to edit another connector:
and I get the twitter's properties instead. If I delete twitter and try again I get: