mirror of
https://github.com/containers/podman.git
synced 2026-10-20 17:05:07 -04: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:
1 file changed
+12
-23
@@ -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]
|
||||
|
||||
|
||||
Reference in new issue
Block a user