diff options
author | W. Trevor King <wking@tremily.us> | 2018-12-04 12:50:59 -0800 |
---|---|---|
committer | W. Trevor King <wking@tremily.us> | 2018-12-04 14:46:43 -0800 |
commit | 39df2093e89a2816f317b72a73106166031045e6 (patch) | |
tree | 9b8c6b2c30a9b768023d15527611babd9b8f815c /cmd | |
parent | 650f95cb06cb5a4e979fbe9f9fcd125a229e4e09 (diff) | |
download | podman-39df2093e89a2816f317b72a73106166031045e6.tar.gz podman-39df2093e89a2816f317b72a73106166031045e6.tar.bz2 podman-39df2093e89a2816f317b72a73106166031045e6.zip |
pkg/lookup: Return ID-only pointers on ErrNo*Entries
Callers that only care about the IDs should try to convert the
identifier to an integer before calling the Get* functions, so they
can save the cost of hitting the filesystem and maybe or maybe not
finding the other fields (User.Name, etc.). But callers that *want*
the other fields but only actually need the ID can, with this commit,
just call the Get* function and ignore ErrNo*Entries responses:
user, err := lookup.GetUser(mount, userIDorName)
if err != nil && err != ErrNoPasswdEntries {
return err
}
Previously, they'd have to perform their own integer-conversion
attempt in Get* error handling, with logic like:
user, err := lookup.GetUser(mount, userIDorName)
if err == ErrNoPasswdEntries {
uuid, err := strconv.ParseUint(userIDorName, 10, 32)
if err == nil {
user.Uid = int(uuid)
}
} else if err != nil {
return err
}
Signed-off-by: W. Trevor King <wking@tremily.us>
Diffstat (limited to 'cmd')
0 files changed, 0 insertions, 0 deletions