Convert user tasks and user login state to new cache collections#54491
Convert user tasks and user login state to new cache collections#54491rosstimothy merged 1 commit intomasterfrom
Conversation
| // Clone returns a copy of the member. | ||
| func (u *UserLoginState) Clone() *UserLoginState { | ||
| var copy *UserLoginState | ||
| utils.StrictObjectToStruct(u, ©) |
There was a problem hiding this comment.
Does StrictObjectToStruct export a pointer to a pointer?
There was a problem hiding this comment.
I shamelessly copied this from access lists. It looks like all existing variants of this resource style use the same pattern though. So if it's not correct we need to fix it everywhere.
teleport/api/types/accesslist/accesslist.go
Lines 410 to 414 in a15a952
teleport/api/types/discoveryconfig/discoveryconfig.go
Lines 181 to 185 in a15a952
teleport/api/types/externalauditstorage/externalauditstorage.go
Lines 238 to 242 in a15a952
There was a problem hiding this comment.
Looks like we just pass it to (json.Decoder).Decode so we really don't need the double pointer, though it will work just fine.
There was a problem hiding this comment.
If we changed this to
var copy UserLoginState
utils.StrictObjectToStruct(u, ©)
return ©then ((*UserLoginState)(nil)).Clone() will be equivalent to &UserLoginState{}, right now it returns (*UserLoginState)(nil).
Obviously neither option is in any way sane and we should write or derive some clone function - and awalterschulze/goderive keeps distinguishing itself in making the entirely wrong choices once again, since it will unconditionally use unsafe and reflect to clone private fields of types which is absolutely wild - but in the meantime the way StrictObjectToStruct is being used is the least worst way.
48e2ee3 to
a555751
Compare
Moves the resources to the new cache collection scheme that was introduced in #52210. No additional functionality changes have been made here. This should be a purely mechanical translation to the new internal caching machinery.
a555751 to
cca8328
Compare
Moves the resources to the new cache collection scheme that was introduced in #52210. No additional functionality changes have been made here. This should be a purely mechanical translation to the new internal caching machinery.