Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Proposal] add search interface for go-scm #146

Open
colynn opened this issue Jan 18, 2022 · 0 comments
Open

[Proposal] add search interface for go-scm #146

colynn opened this issue Jan 18, 2022 · 0 comments

Comments

@colynn
Copy link

colynn commented Jan 18, 2022

we know go-scm can work well with Drone, and it can use repo.Find interface to find a specific project.

In our scenario, we hope can use string to search the project list, so whether we can add a search interface for go-scm,

interface

# https://github.com/go-atomci/go-scm/blob/master/scm/search.go#L16
	SearchService interface {
		// Find returns a repository by name.
		FindProjects(context.Context, string) ([]*Repository, *Response, error)
	}

gitlab sample

# gitlab
# https://github.com/go-atomci/go-scm/blob/master/scm/driver/gitlab/search.go#L18
func (s *searchService) FindProjects(ctx context.Context, projectName string) ([]*scm.Repository, *scm.Response, error) {
	path := fmt.Sprintf("api/v4/search?scope=projects&search=%s", encode(projectName))
	out := []*repository{}
	res, err := s.client.do(ctx, "GET", path, nil, &out)
	return convertRepositoryList(out), res, err
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant