code: func RegistryAuthenticationPrivilegedFunc(cli Cli, index *registrytypes.IndexInfo, cmdName string) types.RequestPrivilegeFunc {
  	return func() (string, error) {
  		fmt.Fprintf(cli.Out(), "\nPlease login prior to %s:\n", cmdName)
  		indexServer := registry.GetAuthConfigKey(index)
  		isDefaultRegistry := indexServer == ElectAuthServer(context.Background(), cli)
  		authConfig, err := GetDefaultAuthConfig(cli, true, indexServer, isDefaultRegistry)
  		if err != nil {
  			fmt.Fprintf(cli.Err(), "Unable to retrieve stored credentials for %s, error: %s.\n", indexServer, err)
  		}
  		err = ConfigureAuth(cli, "", "", authConfig, isDefaultRegistry)
  		if err != nil {
  			return "", err
  		}
  		return EncodeAuthToBase64(*authConfig)
  	}
  }
docs: // RegistryAuthenticationPrivilegedFunc returns a RequestPrivilegeFunc from the specified registry index info
  // for the given command.