You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: label.go
    path of file: ./repos/erda/internal/core/legacy/endpoints
    
    the code of the file until where you have to start completion: // Copyright (c) 2021 Terminus, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not 
    
func (e *Endpoints) checkProjectPermission(identityInfo apistructs.IdentityInfo, projectID uint64, action string) error {
	if projectID == 0 {
		return apierrors.ErrCheckPermission.InvalidParameter(fmt.Errorf("no projectID"))
	}
	if identityInfo.IsInternalClient() {
		return nil
	}
	access, err := e.permission.CheckPermission(&apistructs.PermissionCheckRequest{
		UserID:       identityInfo.UserID,
		Scope:        apistructs.ProjectScope,
		ScopeID:      projectID,
		Resource:     apistructs.ProjectResource,
		Action:       action,
		ResourceRole: "",
	})
	if err != nil {
		logrus.Errorf("failed to check project permission, userID: %s, projectID: %d, action: %s, err: %v", identityInfo.UserID, projectID, action, err)
		// return 403. Do Not disclose specific errors to clients, such as: project not found
		return apierrors.ErrCheckPermission.AccessDenied()
	}
	if !access {
		return apierrors.ErrCheckPermission.AccessDenied()
	}
	return nil
}