hunk.code_window: 	return errors.New("upgrade failed: server should have been restarted by the updater")
   }
   func (service *service) checkImageForDocker(ctx context.Context, image string, skipPullImage bool) error {
   	cli, err := client.NewClientWithOpts(client.FromEnv)
   	if err != nil {
   		return errors.Wrap(err, "failed to create docker client")
   	}
  
hunk.labels: keep keep keep keep replace keep keep keep keep
hunk.after_edit: 	cli, err := client.NewClientWithOpts(
   		client.FromEnv,
   		client.WithAPIVersionNegotiation(),
   	)
  
hunk.file_path: api/internal/upgrade/upgrade_docker.go
hunk.type: replace
file: package access
  
  import (
  	"fmt"
  
  	portainer "github.com/portainer/portainer/api"
  	"github.com/portainer/portainer/api/dataservices"
  	"github.com/portainer/portainer/api/http/security"
  )
  
  func hasPermission(
  	dataStore dataservices.DataStore,
  	userID portainer.UserID,
  	endpointID portainer.EndpointID,
  	registry *portainer.Registry,
  ) (hasPermission bool, err error) {
  	user, err := dataStore.User().Read(userID)
  	if err != nil {
  		return
  	}
  
  	if user.Role == portainer.AdministratorRole {
  		return true, err
  	}
  
  	teamMemberships, err := dataStore.TeamMembership().TeamMembershipsByUserID(userID)
  	if err != nil {
  		return
  	}
  
  	hasPermission = security.AuthorizedRegistryAccess(registry, user, teamMemberships, endpointID)
  
  	return
  }
  
  // GetAccessibleRegistry get the registry if the user has permission
  func GetAccessibleRegistry(
  	dataStore dataservices.DataStore,
  	userID portainer.UserID,
  	endpointID portainer.EndpointID,
  	registryID portainer.RegistryID,
  ) (registry *portainer.Registry, err error) {
  
  	registry, err = dataStore.Registry().Read(registryID)
  	if err != nil {
  		return
  	}
  
  	hasPermission, err := hasPermission(dataStore, userID, endpointID, registry)
  	if err != nil {
  		return
  	}
  
  	if !hasPermission {
  		err = fmt.Errorf("user does not has permission to get the registry")
  		return nil, err
  	}
  
  	return
  }
  