Return role info for each role on pathRoleList#3532
Conversation
builtin/logical/ssh/path_roles.go
Outdated
| // with appropriate values for each keyType. If the keyType is invalid, it will retun | ||
| // an error. | ||
| func (b *backend) parseRole(role *sshRole) (map[string]interface{}, error) { | ||
| result := map[string]interface{}{} |
There was a problem hiding this comment.
Is this intended to ensure that this method doesn't return a nil? If not, the implicit make here can be avoided.
There was a problem hiding this comment.
Yea since we are assigning whole result map in the switch statement, we don't have to initialize it right away.
vishalnayak
left a comment
There was a problem hiding this comment.
One minor comment. LGTM! (after the s/roles/key_info)
|
|
||
| // ListResponseWithInfo is used to format a response to a list operation and | ||
| // return the keys as well as a map with corresponding key info. | ||
| func ListResponseWithInfo(keys []string, keyInfo map[string]interface{}) *Response { |
logical/response.go
Outdated
| func ListResponseWithInfo(keys []string, keyInfo map[string]interface{}) *Response { | ||
| resp := ListResponse(keys) | ||
|
|
||
| resp.Data["key_info"] = map[string]interface{}{} |
There was a problem hiding this comment.
You should create the map separately and assign to resp.Data at the end of the response. This avoids having to keep type asserting in the loop...cleaner and faster!
Separately, I'm not sure whether, if there are no actual keys, we should return an empty map, a null value, or not add the key at all.
There was a problem hiding this comment.
I went with not returning "key_info" at all if it's empty, similar to the behavior with "keys".
* oss/master: (30 commits) Handle 'not supplied' case for field type TypeNameString (#3546) Fix deprecated cassandra backend tests (#3543) changelog++ auth/aws: Make disallow_reauthentication and allow_instance_migration mutually exclusive (#3291) changelog++ More Mount Conflict Detection (#2919) Fix swallowed errors in TestRollbackManager_Join() (#3327) changelog++ added AWS enpoint handling (#3416) Seal wrap all root tokens and their leases (#3540) Return group memberships of entity during read (#3526) Add note on support for using rec keys on /sys/rekey (#3517) Add third party tools list to website (#3488) Minor client refactoring (#3539) changelog++ Add PKCS8 marshaling to PKI (#3518) Update SSH list roles docs (#3536) Update gocql dep changelog++ Return role info for each role on pathRoleList (#3532) ...
No description provided.