Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AtomicReconciler semantically incorrect #586

Open
ulrichSchreiner opened this issue Mar 15, 2018 · 1 comment
Open

AtomicReconciler semantically incorrect #586

ulrichSchreiner opened this issue Mar 15, 2018 · 1 comment
Labels

Comments

@ulrichSchreiner
Copy link
Contributor

hi,

in the code of the AtomicReconciler you can see the pattern:

for i := 0; i < len(r.model.Resources()); i++ {
    resource := r.model.Resources()[i]

where model.Resources() returns a map[int]Resource. The upper code only works, if the map is really an array, so the key's in the map are identically to the list of 0..len(r.model.Resources()).

Suppose you have a map like:

{ 
  10 : ressource1,
  20 : ressource2
}

if you use the upper loop, you will loop from 0..1 and use these two numbers as keys in the map, but this won't work, as the keys in the map in this example are 10 and 20.

you should either use a return type of []Resource for the model.Resource() function or use the range keyword to iterate over the map and get the correct keys. i think the current code is semantically incorrect.

yeah, you are creating the model's with consecutive numbers, but this is an implemetation issue, which is not guaranteed by the signature of the type. and it is very strange if you want to understand the code, to see constructs like this :-)

@krisnova
Copy link
Member

Hi, so this is a reflection of our migration strategy and not our inability to understand Go.

We know it's weird, and we are working on refactoring it. #572 was the first step in this effort.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants