summaryrefslogtreecommitdiff
path: root/libpod/state_test.go
diff options
context:
space:
mode:
authorW. Trevor King <wking@tremily.us>2018-12-04 12:50:59 -0800
committerW. Trevor King <wking@tremily.us>2018-12-04 14:46:43 -0800
commit39df2093e89a2816f317b72a73106166031045e6 (patch)
tree9b8c6b2c30a9b768023d15527611babd9b8f815c /libpod/state_test.go
parent650f95cb06cb5a4e979fbe9f9fcd125a229e4e09 (diff)
downloadpodman-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 'libpod/state_test.go')
0 files changed, 0 insertions, 0 deletions