podman/pkg/lookup
W. Trevor King 39df2093e8 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>
2018-12-04 14:46:43 -08:00
..
lookup.go pkg/lookup: Return ID-only pointers on ErrNo*Entries 2018-12-04 14:46:43 -08:00