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: remotesource.go
    path of file: ./repos/agola/internal/services/configstore/action
    
    the code of the file until where you have to start completion: // Copyright 2019 Sorint.lab
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied
// See the License for the specific language governing permissions and
// limitations under the License.

package action

import (
	"context"

	"github.com/sorintlab/errors"

	"agola.io/agola/internal/sqlg/sql"
	"agola.io/agola/internal/util"
	"agola.io/agola/services/configstore/types"
)

type GetRemoteSourcesRequest struct {
	StartRemoteSourceName string

	Limit         int
	SortDirection types.SortDirection
}

type GetRemoteSourcesResponse struct {
	RemoteSources []*types.RemoteSource

	HasMore bool
}

func (h *ActionHandler) GetRemoteSources(ctx context.Context, req *GetRemoteSourcesRequest) (*GetRemoteSourcesResponse, error) {
	limit := req.Limit
	if limit > 0 {
		limit += 1
	}
	if req.SortDirection == "" {
		req.SortDirection = 
    
func (h *ActionHandler) ValidateRemoteSourceReq(ctx context.Context, req *CreateUpdateRemoteSourceRequest) error {
	if req.Name == "" {
		return util.NewAPIError(util.ErrBadRequest, errors.Errorf("remotesource name required"))
	}
	if !util.ValidateName(req.Name) {
		return util.NewAPIError(util.ErrBadRequest, errors.Errorf("invalid remotesource name %q", req.Name))
	}

	if req.Name == "" {
		return util.NewAPIError(util.ErrBadRequest, errors.Errorf("remotesource name required"))
	}
	if req.APIURL == "" {
		return util.NewAPIError(util.ErrBadRequest, errors.Errorf("remotesource api url required"))
	}
	if req.Type == "" {
		return util.NewAPIError(util.ErrBadRequest, errors.Errorf("remotesource type required"))
	}
	if req.AuthType == "" {
		return util.NewAPIError(util.ErrBadRequest, errors.Errorf("remotesource auth type required"))
	}

	// validate if the remotesource type supports the required auth type
	if !types.SourceSupportsAuthType(types.RemoteSourceType(req.Type), types.RemoteSourceAuthType(req.AuthType)) {
		return util.NewAPIError(util.ErrBadRequest, errors.Errorf("remotesource type %q doesn't support auth type %q", req.Type, req.AuthType))
	}
	if req.AuthType == types.RemoteSourceAuthTypeOauth2 {
		if req.Oauth2ClientID == "" {
			return util.NewAPIError(util.ErrBadRequest, errors.Errorf("remotesource oauth2clientid required for auth type %q", types.RemoteSourceAuthTypeOauth2))
		}
		if req.Oauth2ClientSecret == "" {
			return util.NewAPIError(util.ErrBadRequest, errors.Errorf("remotesource oauth2clientsecret required for auth type %q", types.RemoteSourceAuthTypeOauth2))
		}
	}

	return nil
}