mirror of
https://github.com/rocky-linux/peridot.git
synced 2024-11-27 07:26:26 +00:00
plumb API for External Repositories
This commit is contained in:
parent
034fe12c0a
commit
84423b25ab
@ -125,6 +125,7 @@ type Access interface {
|
|||||||
GetPluginsForProject(projectId string) (models.Plugins, error)
|
GetPluginsForProject(projectId string) (models.Plugins, error)
|
||||||
|
|
||||||
GetExternalRepositoriesForProject(projectId string) (models.ExternalRepositories, error)
|
GetExternalRepositoriesForProject(projectId string) (models.ExternalRepositories, error)
|
||||||
|
GetExternalRepository(projectId string, id string) (models.ExternalRepository, error)
|
||||||
DeleteExternalRepositoryForProject(projectId string, externalRepositoryId string) error
|
DeleteExternalRepositoryForProject(projectId string, externalRepositoryId string) error
|
||||||
CreateExternalRepositoryForProject(projectId string, repoURL string, priority *int32, moduleHotfixes bool) (*models.ExternalRepository, error)
|
CreateExternalRepositoryForProject(projectId string, repoURL string, priority *int32, moduleHotfixes bool) (*models.ExternalRepository, error)
|
||||||
FindRepositoriesForPackage(projectId string, pkg string, internalOnly bool) (models.Repositories, error)
|
FindRepositoriesForPackage(projectId string, pkg string, internalOnly bool) (models.Repositories, error)
|
||||||
|
@ -45,6 +45,16 @@ func (a *Access) GetExternalRepositoriesForProject(projectId string) (ret models
|
|||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *Access) GetExternalRepository(projectId string, repoId string) (*models.ExternalRepository, error) {
|
||||||
|
var r models.ExternalRepository
|
||||||
|
err := a.query.Select(&r, "select id, created_at, project_id, url, priority, module_hotfixes from external_repositories where project_id = $1 and id = $2 order by created_at desc", projectId, repoId)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &r, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (a *Access) DeleteExternalRepositoryForProject(projectId string, id string) error {
|
func (a *Access) DeleteExternalRepositoryForProject(projectId string, id string) error {
|
||||||
_, err := a.query.Exec("delete from external_repositories where project_id = $1 and id = $2", projectId, id)
|
_, err := a.query.Exec("delete from external_repositories where project_id = $1 and id = $2", projectId, id)
|
||||||
return err
|
return err
|
||||||
|
@ -236,6 +236,47 @@ func (s *Server) GetRepository(ctx context.Context, req *peridotpb.GetRepository
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Server) ListExternalRepositories(ctx context.Context, req *peridotpb.ListExternalRepositoriesRequest) (*peridotpb.ListExternalRepositoriesResponse, error) {
|
||||||
|
if err := req.ValidateAll(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if err := s.checkPermission(ctx, ObjectProject, req.ProjectId.Value, PermissionView); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
repos, err := s.db.GetExternalRepositoriesForProject(req.ProjectId.Value)
|
||||||
|
if err != nil {
|
||||||
|
s.log.Errorf("could not list repositories: %v", err)
|
||||||
|
return nil, utils.CouldNotRetrieveObjects
|
||||||
|
}
|
||||||
|
|
||||||
|
return &peridotpb.ListExternalRepositoriesResponse {
|
||||||
|
Repositories: repos.ToProto(),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Server) GetExternalRepository(ctx context.Context, req *peridotpb.GetExternalRepositoryRequest) (*peridotpb.GetExternalRepositoryResponse, error) {
|
||||||
|
if err := req.ValidateAll(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if err := s.checkPermission(ctx, ObjectProject, req.ProjectId.Value, PermissionView); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
repos, err := s.db.GetExternalRepositoryForProject(req.ProjectId.Value, &req.Id.Value, false)
|
||||||
|
if err != nil {
|
||||||
|
s.log.Errorf("could not list repositories: %v", err)
|
||||||
|
return nil, utils.CouldNotRetrieveObjects
|
||||||
|
}
|
||||||
|
if len(repos) == 0 {
|
||||||
|
return nil, utils.CouldNotFindObject
|
||||||
|
}
|
||||||
|
|
||||||
|
return &peridotpb.GetRepositoryResponse{
|
||||||
|
Repository: repos[0].ToProto(),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Server) GetProjectCredentials(ctx context.Context, req *peridotpb.GetProjectCredentialsRequest) (*peridotpb.GetProjectCredentialsResponse, error) {
|
func (s *Server) GetProjectCredentials(ctx context.Context, req *peridotpb.GetProjectCredentialsRequest) (*peridotpb.GetProjectCredentialsResponse, error) {
|
||||||
if err := req.ValidateAll(); err != nil {
|
if err := req.ValidateAll(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Loading…
Reference in New Issue
Block a user