getUserFromImageUser gets uid or user name of the image user. If user is numeric, it will be treated as uid; or else, it is treated as user name.
(imageUser string)
| 251 | // getUserFromImageUser gets uid or user name of the image user. |
| 252 | // If user is numeric, it will be treated as uid; or else, it is treated as user name. |
| 253 | func getUserFromImageUser(imageUser string) (*int64, string) { |
| 254 | user := parseUserFromImageUser(imageUser) |
| 255 | // return both nil if user is not specified in the image. |
| 256 | if user == "" { |
| 257 | return nil, "" |
| 258 | } |
| 259 | // user could be either uid or user name. Try to interpret as numeric uid. |
| 260 | uid, err := strconv.ParseInt(user, 10, 64) |
| 261 | if err != nil { |
| 262 | // If user is non numeric, assume it's user name. |
| 263 | return nil, user |
| 264 | } |
| 265 | // If user is a numeric uid. |
| 266 | return &uid, "" |
| 267 | } |
searching dependent graphs…