From f302fe1af5aed2eba5ffddad8e3db748b2e55cf0 Mon Sep 17 00:00:00 2001 From: Riyad Preukschas Date: Fri, 5 Jul 2024 22:52:41 +0200 Subject: [PATCH 1/2] Expose Podman version info --- container/podman/podman.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/container/podman/podman.go b/container/podman/podman.go index 4d2160dbc6..1731998a7e 100644 --- a/container/podman/podman.go +++ b/container/podman/podman.go @@ -108,7 +108,15 @@ func Status() (v1.DockerStatus, error) { return v1.DockerStatus{}, err } - return docker.StatusFromDockerInfo(*podmanInfo) + status, err := docker.StatusFromDockerInfo(*podmanInfo) + if err != nil { + return v1.DockerStatus{}, err + } + + status.Version, _ = VersionString() + status.APIVersion, _ = APIVersionString() + + return status, nil } func GetInfo() (*dockersystem.Info, error) { @@ -127,6 +135,16 @@ func VersionString() (string, error) { return version.Version, nil } +func APIVersionString() (string, error) { + var version dockertypes.Version + err := apiGetRequest("http://d/v1.0.0/version", &version) + if err != nil { + return "Unknown", err + } + + return version.APIVersion, nil +} + func InspectContainer(id string) (dockertypes.ContainerJSON, error) { var data dockertypes.ContainerJSON err := apiGetRequest(fmt.Sprintf("http://d/v1.0.0/containers/%s/json", id), &data) From 4905144c12b35c1a240770b0f772cc4a082cb842 Mon Sep 17 00:00:00 2001 From: Riyad Preukschas Date: Sun, 30 Jun 2024 17:24:02 +0200 Subject: [PATCH 2/2] Improve error handling when determining Podman (API) version --- container/podman/podman.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/container/podman/podman.go b/container/podman/podman.go index 1731998a7e..b2a3e77f6a 100644 --- a/container/podman/podman.go +++ b/container/podman/podman.go @@ -113,8 +113,19 @@ func Status() (v1.DockerStatus, error) { return v1.DockerStatus{}, err } - status.Version, _ = VersionString() - status.APIVersion, _ = APIVersionString() + podmanVersion, err := VersionString() + if err != nil { + // status.Version will be "Unknown" + return status, err + } + status.Version = podmanVersion + + podmanAPIVersion, err := APIVersionString() + if err != nil { + // status.APIVersion will be "Unknown" + return status, err + } + status.APIVersion = podmanAPIVersion return status, nil }