mirror of
https://github.com/moby/moby.git
synced 2026-07-13 11:00:42 +00:00
commit a0807e7cfe configured golangci-lint
to use go1.23 semantics, which alowed linters like `copyloopvar` to lint
using thee correct semantics.
go1.22 now creates a copy of variables when assigned in a loop; make sure we
don't have files that may downgrade semantics to go1.21 in case that also means
disabling that feature; https://go.dev/ref/spec#Go_1.22
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
55 lines
1.7 KiB
Go
55 lines
1.7 KiB
Go
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
|
|
//go:build go1.22
|
|
|
|
package system // import "github.com/docker/docker/api/server/router/system"
|
|
|
|
import (
|
|
"github.com/docker/docker/api/server/router"
|
|
"github.com/docker/docker/api/types/system"
|
|
buildkit "github.com/docker/docker/builder/builder-next"
|
|
"resenje.org/singleflight"
|
|
)
|
|
|
|
// systemRouter provides information about the Docker system overall.
|
|
// It gathers information about host, daemon and container events.
|
|
type systemRouter struct {
|
|
backend Backend
|
|
cluster ClusterBackend
|
|
routes []router.Route
|
|
builder *buildkit.Builder
|
|
features func() map[string]bool
|
|
|
|
// collectSystemInfo is a single-flight for the /info endpoint,
|
|
// unique per API version (as different API versions may return
|
|
// a different API response).
|
|
collectSystemInfo singleflight.Group[string, *system.Info]
|
|
}
|
|
|
|
// NewRouter initializes a new system router
|
|
func NewRouter(b Backend, c ClusterBackend, builder *buildkit.Builder, features func() map[string]bool) router.Router {
|
|
r := &systemRouter{
|
|
backend: b,
|
|
cluster: c,
|
|
builder: builder,
|
|
features: features,
|
|
}
|
|
|
|
r.routes = []router.Route{
|
|
router.NewOptionsRoute("/{anyroute:.*}", optionsHandler),
|
|
router.NewGetRoute("/_ping", r.pingHandler),
|
|
router.NewHeadRoute("/_ping", r.pingHandler),
|
|
router.NewGetRoute("/events", r.getEvents),
|
|
router.NewGetRoute("/info", r.getInfo),
|
|
router.NewGetRoute("/version", r.getVersion),
|
|
router.NewGetRoute("/system/df", r.getDiskUsage),
|
|
router.NewPostRoute("/auth", r.postAuth),
|
|
}
|
|
|
|
return r
|
|
}
|
|
|
|
// Routes returns all the API routes dedicated to the docker system
|
|
func (s *systemRouter) Routes() []router.Route {
|
|
return s.routes
|
|
}
|