Repository navigation
Cleanup impersonating code - #13630
Conversation
| return config | ||
| } | ||
|
|
||
| // NewImpersonatingOpenShiftClient returns an OS client that will impersonate a user, including user, groups, and scopes |
There was a problem hiding this comment.
s/OS/OpenShift/ but maybe we should call it Origin?
|
|
||
| func NewTemplateInstanceController(restconfig *restclient.Config) *TemplateInstanceController { | ||
| c := TemplateInstanceController{restconfig: restconfig, templateclient: templateclientset.NewForConfigOrDie(restconfig)} | ||
| func NewTemplateInstanceController(restconfig restclient.Config) *TemplateInstanceController { |
There was a problem hiding this comment.
this file is missing godoc entirely, but I blame @jim-minter ;-)
There was a problem hiding this comment.
why did this change from a reference to a value arg?
There was a problem hiding this comment.
i think we usually don't pass pointers that can be mutated inside the function and break the other callers?
There was a problem hiding this comment.
(for things like client configs ;-)
There was a problem hiding this comment.
hm. i would have argued we normally pass pointers because it's more efficient.
There was a problem hiding this comment.
(and because doing a shallow copy gives you a false sense of security where you can still mutate parts of the original object. at least when you take a pointer you know you need to be careful)
|
one naming nit, but LGTM otherwise... nice job @enj! |
Signed-off-by: Monis Khan <[email protected]>
5d516dc to
59965e4
Compare
|
Evaluated for origin test up to 59965e4 |
|
Evaluated for origin testextended up to 59965e4 |
|
continuous-integration/openshift-jenkins/testextended SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_request_origin_extended/122/) (Base Commit: 801b564) (Extended Tests: core(templates)) |
|
aside from some of the changes from pointers to values for reasons that aren't clear to me, this looks ok. (i understand the cases where the type went from struct to interface, but that doesn't appear to be the case for all the changes) |
|
continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_request_origin/574/) (Base Commit: 801b564) |
Per David's request #11647 (comment)
Even though the
I do not really disagree with this. I think the general argument with |
|
LGTM, as well. |
|
[merge] |
|
Evaluated for origin merge up to 59965e4 |
|
continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/merge_pull_request_origin/265/) (Base Commit: b7a5b0f) (Image: devenv-rhel7_6119) |
|
@enj late reply as was on PTO. The NewImpersonating.*Client.* stuff is great, but what was the rationale for everything else - e.g. removing the kc, oc struct members and replacing them with secretsGetter, localSAR, and the general move from struct types to more specific interfaces? |
Nothing should ever use the concrete struct types unless you need to do some hacky manipulations of the fields, which should already tell you that something is wrong. Furthermore, I would expect every single one of these methods to have unit tests. That is physically impossible with the structs - you have use the interfaces to mock things out. See oauthclientregistry.go and oauthclientregistry_test.go for examples. |
|
thanks @enj |
I broke this out of #11647 since it was getting a bit large. @mfojtik @soltysh can one of you take a look?
[test][testextended][extended:core(templates)]
cc @jim-minter since this touches broker stuff (should have no change in functionality).
Signed-off-by: Monis Khan [email protected]