8000 [Backport #811 MGDAPI-5152] remove duplicate env by eguzki · Pull Request #816 · 3scale/3scale-operator · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[Backport #811 MGDAPI-5152] remove duplicate env #816

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

Merged
merged 4 commits into from
Apr 17, 2023

Conversation

eguzki
Copy link
Member
@eguzki eguzki commented Apr 14, 2023

What

Provides support for OCP 4.13 for 3scale 2.13

Fix in master #811

@eguzki eguzki requested a review from a team April 14, 2023 15:03
}
}

return result
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Help me understand where in this function the env vars are actually removed.

ADBF Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The map has the property that the map keys are unique. The method will iterate over all the env vars and try to create a map of env var key to the same env var.

{env var key A} -> {env var A}
{env var key B} -> {env var B}
{env var key C} -> {env var C}

On each iteration of the loop, the map can tell if the key has been inserted before or not (line 17) (in O(1) time). When there are duplicated env vars, the loop will try to insert the same key multiple times in the map. Only the first time will succeed. After that, when a duplicated key is found, the conditional (line 17) will evaluate to false and the duplicated env var will not be added to the list of env vars that is returned by the method.

@eguzki eguzki merged commit 08c8cdc into 3scale-2.13-stable Apr 17, 2023
@eguzki eguzki deleted the backport-811-MGDAPI-5152-duplicate-env branch April 17, 2023 08:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0