MCPcopy Create free account
hub / github.com/coder/envbuilder / UserFromImage

Function UserFromImage

devcontainer/devcontainer.go:483–493  ·  view source on GitHub ↗

UserFromImage inspects the remote reference and returns the user that will be used to run the container.

(ref name.Reference)

Source from the content-addressed store, hash-verified

481// UserFromImage inspects the remote reference and returns the user
482// that will be used to run the container.
483func 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}

Callers 2

TestUserFromFunction · 0.92
UserFromDockerfileFunction · 0.85

Calls 3

ImageMethod · 0.80
ConfigFileMethod · 0.80
NameMethod · 0.45

Tested by 1

TestUserFromFunction · 0.74