mirror of
https://github.com/podman-container-tools/podman.git
synced 2026-09-21 15:17:59 +00:00
api: fix slow version endpoint
This endpoint queried the same package versions twice causing it to be slower than info. Because it already called info we can just reuse the package versions from there. Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
parent
7cd1fb77f9
commit
70428baef3
1 changed files with 12 additions and 23 deletions
|
|
@ -13,7 +13,6 @@ import (
|
|||
"github.com/containers/podman/v4/pkg/domain/entities"
|
||||
"github.com/containers/podman/v4/pkg/domain/entities/types"
|
||||
"github.com/containers/podman/v4/version"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func VersionHandler(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
@ -45,30 +44,20 @@ func VersionHandler(w http.ResponseWriter, r *http.Request) {
|
|||
"MinAPIVersion": version.APIVersion[version.Libpod][version.MinimalAPI].String(),
|
||||
"Os": goRuntime.GOOS,
|
||||
},
|
||||
}, {
|
||||
Name: "Conmon",
|
||||
Version: info.Host.Conmon.Version,
|
||||
Details: map[string]string{
|
||||
"Package": info.Host.Conmon.Package,
|
||||
},
|
||||
}, {
|
||||
Name: fmt.Sprintf("OCI Runtime (%s)", info.Host.OCIRuntime.Name),
|
||||
Version: info.Host.OCIRuntime.Version,
|
||||
Details: map[string]string{
|
||||
"Package": info.Host.OCIRuntime.Package,
|
||||
},
|
||||
}}
|
||||
|
||||
if conmon, oci, err := runtime.DefaultOCIRuntime().RuntimeInfo(); err != nil {
|
||||
logrus.Warnf("Failed to retrieve Conmon and OCI Information: %q", err.Error())
|
||||
} else {
|
||||
additional := []types.ComponentVersion{
|
||||
{
|
||||
Name: "Conmon",
|
||||
Version: conmon.Version,
|
||||
Details: map[string]string{
|
||||
"Package": conmon.Package,
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: fmt.Sprintf("OCI Runtime (%s)", oci.Name),
|
||||
Version: oci.Version,
|
||||
Details: map[string]string{
|
||||
"Package": oci.Package,
|
||||
},
|
||||
},
|
||||
}
|
||||
components = append(components, additional...)
|
||||
}
|
||||
|
||||
apiVersion := version.APIVersion[version.Compat][version.CurrentAPI]
|
||||
minVersion := version.APIVersion[version.Compat][version.MinimalAPI]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue