UserFromImage inspects the remote reference and returns the user that will be used to run the container.
(ref name.Reference)
| 481 | // UserFromImage inspects the remote reference and returns the user |
| 482 | // that will be used to run the container. |
| 483 | func UserFromImage(ref name.Reference) (string, error) { |
| 484 | image, err := remote.Image(ref, remote.WithAuthFromKeychain(creds.GetKeychain())) |
| 485 | if err != nil { |
| 486 | return "", fmt.Errorf("fetch image %s: %w", ref.Name(), err) |
| 487 | } |
| 488 | config, err := image.ConfigFile() |
| 489 | if err != nil { |
| 490 | return "", fmt.Errorf("fetch config %s: %w", ref.Name(), err) |
| 491 | } |
| 492 | return config.Config.User, nil |
| 493 | } |