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

Add some documentation to packages #21648

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions routers/api/packages/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ func reqPackageAccess(accessMode perm.AccessMode) func(ctx *context.Context) {
}
}

func Routes(ctx gocontext.Context) *web.Route {
// CommonRoutes provide endpoints for most package managers (excepting docker HUB - see below)
lunny marked this conversation as resolved.
Show resolved Hide resolved
zeripath marked this conversation as resolved.
Show resolved Hide resolved
// These are mounted on `/api/packages` (not `/api/v1/packages`)
func CommonRoutes(ctx gocontext.Context) *web.Route {
r := web.NewRoute()

r.Use(context.PackageContexter(ctx))
Expand Down Expand Up @@ -301,7 +303,9 @@ func Routes(ctx gocontext.Context) *web.Route {
return r
}

func ContainerRoutes(ctx gocontext.Context) *web.Route {
// DockerContainerRoutes provides endpoints that match the Docker HUB API in order for facilitate downloading packages a docker packages
lunny marked this conversation as resolved.
Show resolved Hide resolved
// These have to be mounted on `/v2/...` due to compatibility with the Docker HUB API
func DockerContainerRoutes(ctx gocontext.Context) *web.Route {
zeripath marked this conversation as resolved.
Show resolved Hide resolved
r := web.NewRoute()

r.Use(context.PackageContexter(ctx))
Expand Down
1 change: 1 addition & 0 deletions routers/api/v1/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,7 @@ func Routes(ctx gocontext.Context) *web.Route {
}, repoAssignment())
})

// NOTE: these are Gitea package management API - see packages.CommonRoutes and packages.DockerContainerRoutes for endpoints to see implementations of package manager APIs
zeripath marked this conversation as resolved.
Show resolved Hide resolved
m.Group("/packages/{username}", func() {
m.Group("/{type}/{name}/{version}", func() {
m.Get("", packages.GetPackage)
Expand Down
10 changes: 8 additions & 2 deletions routers/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,15 @@ func NormalRoutes(ctx context.Context) *web.Route {
r.Mount("/", web_routers.Routes(ctx))
r.Mount("/api/v1", apiv1.Routes(ctx))
r.Mount("/api/internal", private.Routes())

if setting.Packages.Enabled {
r.Mount("/api/packages", packages_router.Routes(ctx))
r.Mount("/v2", packages_router.ContainerRoutes(ctx))
// Add endpoints to match common package manager APIs

// This implements package support for most package managers
r.Mount("/api/packages", packages_router.CommonRoutes(ctx))

// This implements Docker HUB API (Note this is not preceded by /api but is instead /v2)
r.Mount("/v2", packages_router.DockerContainerRoutes(ctx))
lunny marked this conversation as resolved.
Show resolved Hide resolved
zeripath marked this conversation as resolved.
Show resolved Hide resolved
}
return r
}