diff options
author | Jhon Honce <jhonce@redhat.com> | 2020-05-08 10:16:14 -0700 |
---|---|---|
committer | Jhon Honce <jhonce@redhat.com> | 2020-05-08 15:57:26 -0700 |
commit | 931bd5ace6d6efa19e0b123d8d70b273ea79d5ab (patch) | |
tree | b60a06da9fcc73f66be53eae6db86db8342f7fab /pkg/bindings | |
parent | 5c7ac1ba7812a99e59251cf49f7fb2a9c2429e11 (diff) | |
download | podman-931bd5ace6d6efa19e0b123d8d70b273ea79d5ab.tar.gz podman-931bd5ace6d6efa19e0b123d8d70b273ea79d5ab.tar.bz2 podman-931bd5ace6d6efa19e0b123d8d70b273ea79d5ab.zip |
V2 Impliment tunnelled podman version
Signed-off-by: Jhon Honce <jhonce@redhat.com>
Diffstat (limited to 'pkg/bindings')
-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 +} |