diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-05-09 23:04:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-09 23:04:23 +0200 |
commit | 3ff96383f306cecfeed75986078144ad757e3d70 (patch) | |
tree | 301a71ee7621be9d6bfd1b77552c1574f5fc18d2 /pkg/bindings/system | |
parent | 2a6487c4aaa312e9284d223540e971b109d0fcf2 (diff) | |
parent | 931bd5ace6d6efa19e0b123d8d70b273ea79d5ab (diff) | |
download | podman-3ff96383f306cecfeed75986078144ad757e3d70.tar.gz podman-3ff96383f306cecfeed75986078144ad757e3d70.tar.bz2 podman-3ff96383f306cecfeed75986078144ad757e3d70.zip |
Merge pull request #6148 from jwhonce/wip/version
V2 Implement tunnelled podman version
Diffstat (limited to 'pkg/bindings/system')
-rw-r--r-- | pkg/bindings/system/system.go | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/pkg/bindings/system/system.go b/pkg/bindings/system/system.go index df6b529de..caef6af6f 100644 --- a/pkg/bindings/system/system.go +++ b/pkg/bindings/system/system.go @@ -3,11 +3,14 @@ package system import ( "context" "encoding/json" + "fmt" "io" "net/http" "net/url" "strconv" + "time" + "github.com/containers/libpod/libpod/define" "github.com/containers/libpod/pkg/bindings" "github.com/containers/libpod/pkg/domain/entities" "github.com/pkg/errors" @@ -83,3 +86,38 @@ func Prune(ctx context.Context, all, volumes *bool) (*entities.SystemPruneReport } return &report, response.Process(&report) } + +func Version(ctx context.Context) (*entities.SystemVersionReport, error) { + var report entities.SystemVersionReport + var component entities.ComponentVersion + + version, err := define.GetVersion() + if err != nil { + return nil, err + } + report.Client = &version + + conn, err := bindings.GetClient(ctx) + if err != nil { + return nil, err + } + response, err := conn.DoRequest(nil, http.MethodGet, "/version", nil) + if err != nil { + return nil, err + } + + if err = response.Process(&component); err != nil { + return nil, err + } + f, _ := strconv.ParseFloat(component.APIVersion, 64) + b, _ := time.Parse(time.RFC3339, component.BuildTime) + report.Server = &define.Version{ + RemoteAPIVersion: int64(f), + Version: component.Version.Version, + GoVersion: component.GoVersion, + GitCommit: component.GitCommit, + Built: b.Unix(), + OsArch: fmt.Sprintf("%s/%s", component.Os, component.Arch), + } + return &report, err +} |