-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Clone policy permissions and then use existing values rather than policy values for modifications #2826
Conversation
values for modifications. Should fix #2804
} | ||
|
||
switch { | ||
case p.AllowedParameters == nil: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Jeff why do we need both a nil check and a len == 0 check, Can you please add a comment to help understand it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sure that the clone is an exact clone. A map of length 0 is an empty map, but not the same as a nil (unallocated) map.
case len(p.AllowedParameters) == 0: | ||
ret.AllowedParameters = make(map[string][]interface{}) | ||
default: | ||
clonedAllowed, err := copystructure.Copy(p.AllowedParameters) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copy structure might cover the above case as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, just doing this for efficiency rather than call into it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just that one comment, otherwise looks great!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Should fix #2804
Note: this may have some performance impact, although how much will depend on whether there is allowed_parameters/denied_parameters. We may be able to speed that up, but at the moment I'm preferring correctness over speed.