Hide private repositories in packages (#19584)

This commit is contained in:
KN4CK3R 2022-05-07 18:21:15 +02:00 committed by GitHub
parent 38d72d40f1
commit 8adba93498
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 115 additions and 20 deletions

View file

@ -73,7 +73,12 @@ func ListPackages(ctx *context.APIContext) {
apiPackages := make([]*api.Package, 0, len(pds))
for _, pd := range pds {
apiPackages = append(apiPackages, convert.ToPackage(pd))
apiPackage, err := convert.ToPackage(ctx, pd, ctx.Doer)
if err != nil {
ctx.Error(http.StatusInternalServerError, "Error converting package for api", err)
return
}
apiPackages = append(apiPackages, apiPackage)
}
ctx.SetLinkHeader(int(count), listOptions.PageSize)
@ -115,7 +120,13 @@ func GetPackage(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
ctx.JSON(http.StatusOK, convert.ToPackage(ctx.Package.Descriptor))
apiPackage, err := convert.ToPackage(ctx, ctx.Package.Descriptor, ctx.Doer)
if err != nil {
ctx.Error(http.StatusInternalServerError, "Error converting package for api", err)
return
}
ctx.JSON(http.StatusOK, apiPackage)
}
// DeletePackage deletes a package