Add GetPkg endpoint to API

This commit is contained in:
Elara 2022-12-17 23:10:34 -08:00
parent 49497c6534
commit c4ad6187b1
5 changed files with 521 additions and 129 deletions

View File

@ -122,28 +122,40 @@ func (l lureWebAPI) Search(ctx context.Context, req *api.SearchRequest) (*api.Se
if err != nil {
return err
}
out.Packages = append(out.Packages, &api.Package{
Name: pkg.Name,
Repository: pkg.Repository,
Version: pkg.Version,
Release: int64(pkg.Release),
Epoch: ptr(int64(pkg.Epoch)),
Description: &pkg.Description,
Homepage: &pkg.Homepage,
Maintainer: &pkg.Maintainer,
Architectures: pkg.Architectures,
Licenses: pkg.Licenses,
Provides: pkg.Provides,
Conflicts: pkg.Conflicts,
Replaces: pkg.Replaces,
Depends: dbMapToAPI(pkg.Depends),
BuildDepends: dbMapToAPI(pkg.BuildDepends),
})
out.Packages = append(out.Packages, dbPkgToAPI(pkg))
return nil
})
return out, err
}
func (l lureWebAPI) GetPkg(ctx context.Context, req *api.GetPackageRequest) (*api.Package, error) {
pkg, err := db.GetPkg(l.db, "name = ? AND repository = ?", req.Name, req.Repository)
if err != nil {
return nil, err
}
return dbPkgToAPI(pkg), nil
}
func dbPkgToAPI(pkg *db.Package) *api.Package {
return &api.Package{
Name: pkg.Name,
Repository: pkg.Repository,
Version: pkg.Version,
Release: int64(pkg.Release),
Epoch: ptr(int64(pkg.Epoch)),
Description: &pkg.Description,
Homepage: &pkg.Homepage,
Maintainer: &pkg.Maintainer,
Architectures: pkg.Architectures,
Licenses: pkg.Licenses,
Provides: pkg.Provides,
Conflicts: pkg.Conflicts,
Replaces: pkg.Replaces,
Depends: dbMapToAPI(pkg.Depends),
BuildDepends: dbMapToAPI(pkg.BuildDepends),
}
}
func ptr[T any](v T) *T {
return &v
}

View File

@ -801,6 +801,61 @@ func (x *Package) GetBuildDepends() map[string]*StringList {
return nil
}
type GetPackageRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Repository string `protobuf:"bytes,2,opt,name=repository,proto3" json:"repository,omitempty"`
}
func (x *GetPackageRequest) Reset() {
*x = GetPackageRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_lure_proto_msgTypes[10]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetPackageRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetPackageRequest) ProtoMessage() {}
func (x *GetPackageRequest) ProtoReflect() protoreflect.Message {
mi := &file_lure_proto_msgTypes[10]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetPackageRequest.ProtoReflect.Descriptor instead.
func (*GetPackageRequest) Descriptor() ([]byte, []int) {
return file_lure_proto_rawDescGZIP(), []int{10}
}
func (x *GetPackageRequest) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *GetPackageRequest) GetRepository() string {
if x != nil {
return x.Repository
}
return ""
}
// SearchResponse contains returned packages
type SearchResponse struct {
state protoimpl.MessageState
@ -813,7 +868,7 @@ type SearchResponse struct {
func (x *SearchResponse) Reset() {
*x = SearchResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_lure_proto_msgTypes[10]
mi := &file_lure_proto_msgTypes[11]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -826,7 +881,7 @@ func (x *SearchResponse) String() string {
func (*SearchResponse) ProtoMessage() {}
func (x *SearchResponse) ProtoReflect() protoreflect.Message {
mi := &file_lure_proto_msgTypes[10]
mi := &file_lure_proto_msgTypes[11]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -839,7 +894,7 @@ func (x *SearchResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use SearchResponse.ProtoReflect.Descriptor instead.
func (*SearchResponse) Descriptor() ([]byte, []int) {
return file_lure_proto_rawDescGZIP(), []int{10}
return file_lure_proto_rawDescGZIP(), []int{11}
}
func (x *SearchResponse) GetPackages() []*Package {
@ -951,37 +1006,45 @@ var file_lure_proto_rawDesc = []byte{
0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x08, 0x0a, 0x06, 0x5f, 0x65, 0x70, 0x6f, 0x63, 0x68,
0x42, 0x0e, 0x0a, 0x0c, 0x5f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e,
0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x68, 0x6f, 0x6d, 0x65, 0x70, 0x61, 0x67, 0x65, 0x42, 0x0d, 0x0a,
0x0b, 0x5f, 0x6d, 0x61, 0x69, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x22, 0x3b, 0x0a, 0x0e,
0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x29,
0x0a, 0x08, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b,
0x32, 0x0d, 0x2e, 0x6c, 0x75, 0x72, 0x65, 0x2e, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x52,
0x08, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x73, 0x2a, 0x3e, 0x0a, 0x07, 0x53, 0x4f, 0x52,
0x54, 0x5f, 0x42, 0x59, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x4e, 0x53, 0x4f, 0x52, 0x54, 0x45, 0x44,
0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x4e, 0x41, 0x4d, 0x45, 0x10, 0x01, 0x12, 0x0e, 0x0a, 0x0a,
0x52, 0x45, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x4f, 0x52, 0x59, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07,
0x56, 0x45, 0x52, 0x53, 0x49, 0x4f, 0x4e, 0x10, 0x03, 0x2a, 0x42, 0x0a, 0x0b, 0x46, 0x49, 0x4c,
0x54, 0x45, 0x52, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x12, 0x0d, 0x0a, 0x09, 0x4e, 0x4f, 0x5f, 0x46,
0x49, 0x4c, 0x54, 0x45, 0x52, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d, 0x49, 0x4e, 0x5f, 0x52, 0x45,
0x50, 0x4f, 0x53, 0x49, 0x54, 0x4f, 0x52, 0x59, 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x55,
0x50, 0x50, 0x4f, 0x52, 0x54, 0x53, 0x5f, 0x41, 0x52, 0x43, 0x48, 0x10, 0x02, 0x32, 0x86, 0x02,
0x0a, 0x03, 0x41, 0x50, 0x49, 0x12, 0x48, 0x0a, 0x0d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x43,
0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x1a, 0x2e, 0x6c, 0x75, 0x72, 0x65, 0x2e, 0x43, 0x72,
0x65, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x6c, 0x75, 0x72, 0x65, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65,
0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12,
0x3c, 0x0a, 0x0b, 0x45, 0x64, 0x69, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x18,
0x2e, 0x6c, 0x75, 0x72, 0x65, 0x2e, 0x45, 0x64, 0x69, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e,
0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x6c, 0x75, 0x72, 0x65, 0x2e,
0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x42, 0x0a,
0x0b, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x18, 0x2e, 0x6c,
0x75, 0x72, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x6c, 0x75, 0x72, 0x65, 0x2e, 0x47, 0x65,
0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x12, 0x33, 0x0a, 0x06, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x12, 0x13, 0x2e, 0x6c, 0x75,
0x72, 0x65, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x1a, 0x14, 0x2e, 0x6c, 0x75, 0x72, 0x65, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x0f, 0x5a, 0x0d, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72,
0x6e, 0x61, 0x6c, 0x2f, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x0b, 0x5f, 0x6d, 0x61, 0x69, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x22, 0x47, 0x0a, 0x11,
0x47, 0x65, 0x74, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74,
0x6f, 0x72, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x72, 0x65, 0x70, 0x6f, 0x73,
0x69, 0x74, 0x6f, 0x72, 0x79, 0x22, 0x3b, 0x0a, 0x0e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52,
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x29, 0x0a, 0x08, 0x70, 0x61, 0x63, 0x6b, 0x61,
0x67, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x6c, 0x75, 0x72, 0x65,
0x2e, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x52, 0x08, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67,
0x65, 0x73, 0x2a, 0x3e, 0x0a, 0x07, 0x53, 0x4f, 0x52, 0x54, 0x5f, 0x42, 0x59, 0x12, 0x0c, 0x0a,
0x08, 0x55, 0x4e, 0x53, 0x4f, 0x52, 0x54, 0x45, 0x44, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x4e,
0x41, 0x4d, 0x45, 0x10, 0x01, 0x12, 0x0e, 0x0a, 0x0a, 0x52, 0x45, 0x50, 0x4f, 0x53, 0x49, 0x54,
0x4f, 0x52, 0x59, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x56, 0x45, 0x52, 0x53, 0x49, 0x4f, 0x4e,
0x10, 0x03, 0x2a, 0x42, 0x0a, 0x0b, 0x46, 0x49, 0x4c, 0x54, 0x45, 0x52, 0x5f, 0x54, 0x59, 0x50,
0x45, 0x12, 0x0d, 0x0a, 0x09, 0x4e, 0x4f, 0x5f, 0x46, 0x49, 0x4c, 0x54, 0x45, 0x52, 0x10, 0x00,
0x12, 0x11, 0x0a, 0x0d, 0x49, 0x4e, 0x5f, 0x52, 0x45, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x4f, 0x52,
0x59, 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x55, 0x50, 0x50, 0x4f, 0x52, 0x54, 0x53, 0x5f,
0x41, 0x52, 0x43, 0x48, 0x10, 0x02, 0x32, 0xb8, 0x02, 0x0a, 0x03, 0x41, 0x50, 0x49, 0x12, 0x48,
0x0a, 0x0d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x12,
0x1a, 0x2e, 0x6c, 0x75, 0x72, 0x65, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6d,
0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x6c, 0x75,
0x72, 0x65, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74,
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3c, 0x0a, 0x0b, 0x45, 0x64, 0x69, 0x74,
0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x18, 0x2e, 0x6c, 0x75, 0x72, 0x65, 0x2e, 0x45,
0x64, 0x69, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x1a, 0x13, 0x2e, 0x6c, 0x75, 0x72, 0x65, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x42, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6d,
0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x18, 0x2e, 0x6c, 0x75, 0x72, 0x65, 0x2e, 0x47, 0x65, 0x74,
0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
0x19, 0x2e, 0x6c, 0x75, 0x72, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e,
0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x33, 0x0a, 0x06, 0x53, 0x65,
0x61, 0x72, 0x63, 0x68, 0x12, 0x13, 0x2e, 0x6c, 0x75, 0x72, 0x65, 0x2e, 0x53, 0x65, 0x61, 0x72,
0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x6c, 0x75, 0x72, 0x65,
0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12,
0x30, 0x0a, 0x06, 0x47, 0x65, 0x74, 0x50, 0x6b, 0x67, 0x12, 0x17, 0x2e, 0x6c, 0x75, 0x72, 0x65,
0x2e, 0x47, 0x65, 0x74, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x1a, 0x0d, 0x2e, 0x6c, 0x75, 0x72, 0x65, 0x2e, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67,
0x65, 0x42, 0x0f, 0x5a, 0x0d, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x61,
0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@ -997,7 +1060,7 @@ func file_lure_proto_rawDescGZIP() []byte {
}
var file_lure_proto_enumTypes = make([]protoimpl.EnumInfo, 2)
var file_lure_proto_msgTypes = make([]protoimpl.MessageInfo, 13)
var file_lure_proto_msgTypes = make([]protoimpl.MessageInfo, 14)
var file_lure_proto_goTypes = []interface{}{
(SORT_BY)(0), // 0: lure.SORT_BY
(FILTER_TYPE)(0), // 1: lure.FILTER_TYPE
@ -1011,16 +1074,17 @@ var file_lure_proto_goTypes = []interface{}{
(*SearchRequest)(nil), // 9: lure.SearchRequest
(*StringList)(nil), // 10: lure.StringList
(*Package)(nil), // 11: lure.Package
(*SearchResponse)(nil), // 12: lure.SearchResponse
nil, // 13: lure.Package.DependsEntry
nil, // 14: lure.Package.BuildDependsEntry
(*GetPackageRequest)(nil), // 12: lure.GetPackageRequest
(*SearchResponse)(nil), // 13: lure.SearchResponse
nil, // 14: lure.Package.DependsEntry
nil, // 15: lure.Package.BuildDependsEntry
}
var file_lure_proto_depIdxs = []int32{
3, // 0: lure.GetCommentsResponse.comments:type_name -> lure.Comment
0, // 1: lure.SearchRequest.sort_by:type_name -> lure.SORT_BY
1, // 2: lure.SearchRequest.filter_type:type_name -> lure.FILTER_TYPE
13, // 3: lure.Package.depends:type_name -> lure.Package.DependsEntry
14, // 4: lure.Package.build_depends:type_name -> lure.Package.BuildDependsEntry
14, // 3: lure.Package.depends:type_name -> lure.Package.DependsEntry
15, // 4: lure.Package.build_depends:type_name -> lure.Package.BuildDependsEntry
11, // 5: lure.SearchResponse.packages:type_name -> lure.Package
10, // 6: lure.Package.DependsEntry.value:type_name -> lure.StringList
10, // 7: lure.Package.BuildDependsEntry.value:type_name -> lure.StringList
@ -1028,12 +1092,14 @@ var file_lure_proto_depIdxs = []int32{
6, // 9: lure.API.EditComment:input_type -> lure.EditCommentRequest
7, // 10: lure.API.GetComments:input_type -> lure.GetCommentsRequest
9, // 11: lure.API.Search:input_type -> lure.SearchRequest
5, // 12: lure.API.CreateComment:output_type -> lure.CreateCommentResponse
2, // 13: lure.API.EditComment:output_type -> lure.EmptyResponse
8, // 14: lure.API.GetComments:output_type -> lure.GetCommentsResponse
12, // 15: lure.API.Search:output_type -> lure.SearchResponse
12, // [12:16] is the sub-list for method output_type
8, // [8:12] is the sub-list for method input_type
12, // 12: lure.API.GetPkg:input_type -> lure.GetPackageRequest
5, // 13: lure.API.CreateComment:output_type -> lure.CreateCommentResponse
2, // 14: lure.API.EditComment:output_type -> lure.EmptyResponse
8, // 15: lure.API.GetComments:output_type -> lure.GetCommentsResponse
13, // 16: lure.API.Search:output_type -> lure.SearchResponse
11, // 17: lure.API.GetPkg:output_type -> lure.Package
13, // [13:18] is the sub-list for method output_type
8, // [8:13] is the sub-list for method input_type
8, // [8:8] is the sub-list for extension type_name
8, // [8:8] is the sub-list for extension extendee
0, // [0:8] is the sub-list for field type_name
@ -1166,6 +1232,18 @@ func file_lure_proto_init() {
}
}
file_lure_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetPackageRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_lure_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SearchResponse); i {
case 0:
return &v.state
@ -1186,7 +1264,7 @@ func file_lure_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_lure_proto_rawDesc,
NumEnums: 2,
NumMessages: 13,
NumMessages: 14,
NumExtensions: 0,
NumServices: 1,
},

View File

@ -44,6 +44,9 @@ type API interface {
// Search searches through LURE packages in the database
Search(context.Context, *SearchRequest) (*SearchResponse, error)
// GetPkg gets a single LURE package from the database
GetPkg(context.Context, *GetPackageRequest) (*Package, error)
}
// ===================
@ -52,7 +55,7 @@ type API interface {
type aPIProtobufClient struct {
client HTTPClient
urls [4]string
urls [5]string
interceptor twirp.Interceptor
opts twirp.ClientOptions
}
@ -80,11 +83,12 @@ func NewAPIProtobufClient(baseURL string, client HTTPClient, opts ...twirp.Clien
// Build method URLs: <baseURL>[<prefix>]/<package>.<Service>/<Method>
serviceURL := sanitizeBaseURL(baseURL)
serviceURL += baseServicePath(pathPrefix, "lure", "API")
urls := [4]string{
urls := [5]string{
serviceURL + "CreateComment",
serviceURL + "EditComment",
serviceURL + "GetComments",
serviceURL + "Search",
serviceURL + "GetPkg",
}
return &aPIProtobufClient{
@ -279,13 +283,59 @@ func (c *aPIProtobufClient) callSearch(ctx context.Context, in *SearchRequest) (
return out, nil
}
func (c *aPIProtobufClient) GetPkg(ctx context.Context, in *GetPackageRequest) (*Package, error) {
ctx = ctxsetters.WithPackageName(ctx, "lure")
ctx = ctxsetters.WithServiceName(ctx, "API")
ctx = ctxsetters.WithMethodName(ctx, "GetPkg")
caller := c.callGetPkg
if c.interceptor != nil {
caller = func(ctx context.Context, req *GetPackageRequest) (*Package, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*GetPackageRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*GetPackageRequest) when calling interceptor")
}
return c.callGetPkg(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*Package)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*Package) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *aPIProtobufClient) callGetPkg(ctx context.Context, in *GetPackageRequest) (*Package, error) {
out := new(Package)
ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[4], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
// ===============
// API JSON Client
// ===============
type aPIJSONClient struct {
client HTTPClient
urls [4]string
urls [5]string
interceptor twirp.Interceptor
opts twirp.ClientOptions
}
@ -313,11 +363,12 @@ func NewAPIJSONClient(baseURL string, client HTTPClient, opts ...twirp.ClientOpt
// Build method URLs: <baseURL>[<prefix>]/<package>.<Service>/<Method>
serviceURL := sanitizeBaseURL(baseURL)
serviceURL += baseServicePath(pathPrefix, "lure", "API")
urls := [4]string{
urls := [5]string{
serviceURL + "CreateComment",
serviceURL + "EditComment",
serviceURL + "GetComments",
serviceURL + "Search",
serviceURL + "GetPkg",
}
return &aPIJSONClient{
@ -512,6 +563,52 @@ func (c *aPIJSONClient) callSearch(ctx context.Context, in *SearchRequest) (*Sea
return out, nil
}
func (c *aPIJSONClient) GetPkg(ctx context.Context, in *GetPackageRequest) (*Package, error) {
ctx = ctxsetters.WithPackageName(ctx, "lure")
ctx = ctxsetters.WithServiceName(ctx, "API")
ctx = ctxsetters.WithMethodName(ctx, "GetPkg")
caller := c.callGetPkg
if c.interceptor != nil {
caller = func(ctx context.Context, req *GetPackageRequest) (*Package, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*GetPackageRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*GetPackageRequest) when calling interceptor")
}
return c.callGetPkg(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*Package)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*Package) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *aPIJSONClient) callGetPkg(ctx context.Context, in *GetPackageRequest) (*Package, error) {
out := new(Package)
ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[4], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
// ==================
// API Server Handler
// ==================
@ -621,6 +718,9 @@ func (s *aPIServer) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
case "Search":
s.serveSearch(ctx, resp, req)
return
case "GetPkg":
s.serveGetPkg(ctx, resp, req)
return
default:
msg := fmt.Sprintf("no handler for path %q", req.URL.Path)
s.writeError(ctx, resp, badRouteError(msg, req.Method, req.URL.Path))
@ -1348,6 +1448,186 @@ func (s *aPIServer) serveSearchProtobuf(ctx context.Context, resp http.ResponseW
callResponseSent(ctx, s.hooks)
}
func (s *aPIServer) serveGetPkg(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
header := req.Header.Get("Content-Type")
i := strings.Index(header, ";")
if i == -1 {
i = len(header)
}
switch strings.TrimSpace(strings.ToLower(header[:i])) {
case "application/json":
s.serveGetPkgJSON(ctx, resp, req)
case "application/protobuf":
s.serveGetPkgProtobuf(ctx, resp, req)
default:
msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type"))
twerr := badRouteError(msg, req.Method, req.URL.Path)
s.writeError(ctx, resp, twerr)
}
}
func (s *aPIServer) serveGetPkgJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "GetPkg")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
d := json.NewDecoder(req.Body)
rawReqBody := json.RawMessage{}
if err := d.Decode(&rawReqBody); err != nil {
s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err)
return
}
reqContent := new(GetPackageRequest)
unmarshaler := protojson.UnmarshalOptions{DiscardUnknown: true}
if err = unmarshaler.Unmarshal(rawReqBody, reqContent); err != nil {
s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err)
return
}
handler := s.API.GetPkg
if s.interceptor != nil {
handler = func(ctx context.Context, req *GetPackageRequest) (*Package, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*GetPackageRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*GetPackageRequest) when calling interceptor")
}
return s.API.GetPkg(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*Package)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*Package) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
// Call service method
var respContent *Package
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *Package and nil error while calling GetPkg. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
marshaler := &protojson.MarshalOptions{UseProtoNames: !s.jsonCamelCase, EmitUnpopulated: !s.jsonSkipDefaults}
respBytes, err := marshaler.Marshal(respContent)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
resp.Header().Set("Content-Type", "application/json")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *aPIServer) serveGetPkgProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "GetPkg")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
buf, err := io.ReadAll(req.Body)
if err != nil {
s.handleRequestBodyError(ctx, resp, "failed to read request body", err)
return
}
reqContent := new(GetPackageRequest)
if err = proto.Unmarshal(buf, reqContent); err != nil {
s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded"))
return
}
handler := s.API.GetPkg
if s.interceptor != nil {
handler = func(ctx context.Context, req *GetPackageRequest) (*Package, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*GetPackageRequest)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*GetPackageRequest) when calling interceptor")
}
return s.API.GetPkg(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*Package)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*Package) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
// Call service method
var respContent *Package
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *Package and nil error while calling GetPkg. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
respBytes, err := proto.Marshal(respContent)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
resp.Header().Set("Content-Type", "application/protobuf")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *aPIServer) ServiceDescriptor() ([]byte, int) {
return twirpFileDescriptor0, 0
}
@ -1929,65 +2209,67 @@ func callClientError(ctx context.Context, h *twirp.ClientHooks, err twirp.Error)
}
var twirpFileDescriptor0 = []byte{
// 949 bytes of a gzipped FileDescriptorProto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0xe1, 0x4b, 0x3f,
0x65, 0x57, 0x75, 0xf5, 0x47, 0xf0, 0xea, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x30, 0x56, 0x9a,
0xc2, 0x1f, 0x08, 0x00, 0x00,
// 978 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xef, 0x6e, 0xe3, 0x44,
0x10, 0xaf, 0x93, 0x26, 0x4e, 0xc6, 0x71, 0x9a, 0xee, 0x15, 0xe1, 0x86, 0x3f, 0x57, 0x7c, 0x50,
0x95, 0xfb, 0xd0, 0x43, 0x3d, 0x84, 0x10, 0x20, 0x44, 0xdd, 0x86, 0x36, 0x52, 0x49, 0xc2, 0x26,
0x57, 0xa9, 0x7c, 0xb1, 0x5c, 0x67, 0x2e, 0x5d, 0xc5, 0xff, 0xce, 0xde, 0xf4, 0x94, 0x37, 0x38,
0xf1, 0x44, 0x3c, 0x06, 0x0f, 0xc1, 0x83, 0xa0, 0xdd, 0xb5, 0x53, 0xa7, 0xad, 0x38, 0x09, 0xf8,
0xb6, 0xf3, 0x9b, 0x7f, 0x3b, 0x33, 0x3f, 0xcf, 0x1a, 0x20, 0x58, 0xa4, 0x78, 0x98, 0xa4, 0x31,
0x8f, 0xc9, 0xa6, 0x38, 0xdb, 0x5b, 0x60, 0xf6, 0xc2, 0x84, 0x2f, 0x29, 0x66, 0x49, 0x1c, 0x65,
0x68, 0xcf, 0x40, 0x3f, 0x89, 0xc3, 0x10, 0x23, 0x4e, 0x3e, 0x01, 0xf0, 0xd5, 0xd1, 0x65, 0x53,
0x4b, 0xdb, 0xd3, 0x0e, 0xaa, 0xb4, 0x99, 0x23, 0xfd, 0x29, 0xf9, 0x0c, 0x5a, 0x9c, 0x85, 0xe8,
0xfa, 0x29, 0x7a, 0x1c, 0xa7, 0x56, 0x45, 0x1a, 0x18, 0x02, 0x3b, 0x51, 0x10, 0xe9, 0x42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, 0x13, 0x07, 0x8c, 0xd2, 0xf6, 0x2e, 0xbc, 0x1f, 0x3e, 0x2e, 0xdd, 0xdd, 0x47, 0x34,
0x79, 0x8c, 0x97, 0x50, 0x57, 0x43, 0x21, 0x79, 0x8a, 0xb5, 0x65, 0xde, 0xdd, 0x59, 0x07, 0x73,
0xa7, 0xaf, 0xa0, 0x2e, 0x28, 0x31, 0x9f, 0x91, 0x0f, 0x57, 0x91, 0xd7, 0x09, 0xd2, 0x5d, 0x1f,
0xa4, 0xb3, 0xf5, 0x9b, 0xf9, 0x82, 0x45, 0x1c, 0xd3, 0xc8, 0x0b, 0x5e, 0x78, 0x09, 0xbb, 0xae,
0xcb, 0x9f, 0x91, 0x97, 0x7f, 0x07, 0x00, 0x00, 0xff, 0xff, 0xec, 0xa6, 0x81, 0xb1, 0x9a, 0x08,
0x00, 0x00,
}

View File

@ -90,6 +90,11 @@ message Package {
map<string, StringList> build_depends = 15;
}
message GetPackageRequest {
string name = 1;
string repository = 2;
}
// SearchResponse contains returned packages
message SearchResponse {
repeated Package packages = 1;
@ -106,4 +111,6 @@ service API {
// Search searches through LURE packages in the database
rpc Search(SearchRequest) returns (SearchResponse);
// GetPkg gets a single LURE package from the database
rpc GetPkg(GetPackageRequest) returns (Package);
}

View File

@ -2,6 +2,7 @@ package db
import (
"github.com/genjidb/genji"
"github.com/genjidb/genji/document"
"github.com/genjidb/genji/types"
)
@ -81,6 +82,18 @@ func GetPkgs(db *genji.DB, where string, args ...any) (*genji.Result, error) {
return stream, nil
}
// GetPkg returns a single package that match the where conditions
func GetPkg(db *genji.DB, where string, args ...any) (*Package, error) {
doc, err := db.QueryDocument("SELECT * FROM pkgs WHERE "+where+"LIMIT 1", args...)
if err != nil {
return nil, err
}
out := &Package{}
err = document.ScanDocument(doc, out)
return out, err
}
// DeletePkgs deletes all packages matching the where conditions
func DeletePkgs(db *genji.DB, where string, args ...any) error {
return db.Exec("DELETE FROM pkgs WHERE "+where, args...)