mirror of https://github.com/containers/podman.git
Merge pull request #2199 from baude/remoteversion
enable podman-remote version
This commit is contained in:
commit
7838a13b61
2
API.md
2
API.md
|
@ -1654,6 +1654,8 @@ git_commit [string](https://godoc.org/builtin#string)
|
||||||
built [int](https://godoc.org/builtin#int)
|
built [int](https://godoc.org/builtin#int)
|
||||||
|
|
||||||
os_arch [string](https://godoc.org/builtin#string)
|
os_arch [string](https://godoc.org/builtin#string)
|
||||||
|
|
||||||
|
remote_api_version [int](https://godoc.org/builtin#int)
|
||||||
## Errors
|
## Errors
|
||||||
### <a name="ContainerNotFound"></a>type ContainerNotFound
|
### <a name="ContainerNotFound"></a>type ContainerNotFound
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,6 @@ func getAppCommands() []cli.Command {
|
||||||
topCommand,
|
topCommand,
|
||||||
umountCommand,
|
umountCommand,
|
||||||
unpauseCommand,
|
unpauseCommand,
|
||||||
versionCommand,
|
|
||||||
volumeCommand,
|
volumeCommand,
|
||||||
waitCommand,
|
waitCommand,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"runtime"
|
"fmt"
|
||||||
|
rt "runtime"
|
||||||
|
|
||||||
"github.com/containers/libpod/cmd/podman/formats"
|
"github.com/containers/libpod/cmd/podman/formats"
|
||||||
"github.com/containers/libpod/libpod"
|
"github.com/containers/libpod/libpod"
|
||||||
"github.com/containers/libpod/libpod/adapter"
|
"github.com/containers/libpod/libpod/adapter"
|
||||||
|
"github.com/containers/libpod/version"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
@ -38,6 +40,7 @@ func infoCmd(c *cli.Context) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
info := map[string]interface{}{}
|
info := map[string]interface{}{}
|
||||||
|
remoteClientInfo := map[string]interface{}{}
|
||||||
|
|
||||||
runtime, err := adapter.GetRuntime(c)
|
runtime, err := adapter.GetRuntime(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -49,9 +52,13 @@ func infoCmd(c *cli.Context) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "error getting info")
|
return errors.Wrapf(err, "error getting info")
|
||||||
}
|
}
|
||||||
|
if runtime.Remote {
|
||||||
|
remoteClientInfo["RemoteAPI Version"] = version.RemoteAPIVersion
|
||||||
|
remoteClientInfo["Podman Version"] = version.Version
|
||||||
|
remoteClientInfo["OS Arch"] = fmt.Sprintf("%s/%s", rt.GOOS, rt.GOARCH)
|
||||||
|
infoArr = append(infoArr, libpod.InfoData{Type: "client", Data: remoteClientInfo})
|
||||||
|
}
|
||||||
|
|
||||||
// TODO This is no a problem child because we don't know if we should add information
|
|
||||||
// TODO about the client or the backend. Only do for traditional podman for now.
|
|
||||||
if !runtime.Remote && c.Bool("debug") {
|
if !runtime.Remote && c.Bool("debug") {
|
||||||
debugInfo := debugInfo(c)
|
debugInfo := debugInfo(c)
|
||||||
infoArr = append(infoArr, libpod.InfoData{Type: "debug", Data: debugInfo})
|
infoArr = append(infoArr, libpod.InfoData{Type: "debug", Data: debugInfo})
|
||||||
|
@ -80,8 +87,8 @@ func infoCmd(c *cli.Context) error {
|
||||||
// top-level "debug" info
|
// top-level "debug" info
|
||||||
func debugInfo(c *cli.Context) map[string]interface{} {
|
func debugInfo(c *cli.Context) map[string]interface{} {
|
||||||
info := map[string]interface{}{}
|
info := map[string]interface{}{}
|
||||||
info["compiler"] = runtime.Compiler
|
info["compiler"] = rt.Compiler
|
||||||
info["go version"] = runtime.Version()
|
info["go version"] = rt.Version()
|
||||||
info["podman version"] = c.App.Version
|
info["podman version"] = c.App.Version
|
||||||
version, _ := libpod.GetVersion()
|
version, _ := libpod.GetVersion()
|
||||||
info["git commit"] = version.GitCommit
|
info["git commit"] = version.GitCommit
|
||||||
|
|
|
@ -96,6 +96,7 @@ func main() {
|
||||||
pullCommand,
|
pullCommand,
|
||||||
rmiCommand,
|
rmiCommand,
|
||||||
tagCommand,
|
tagCommand,
|
||||||
|
versionCommand,
|
||||||
}
|
}
|
||||||
|
|
||||||
app.Commands = append(app.Commands, getAppCommands()...)
|
app.Commands = append(app.Commands, getAppCommands()...)
|
||||||
|
|
|
@ -9,7 +9,8 @@ type Version (
|
||||||
go_version: string,
|
go_version: string,
|
||||||
git_commit: string,
|
git_commit: string,
|
||||||
built: int,
|
built: int,
|
||||||
os_arch: string
|
os_arch: string,
|
||||||
|
remote_api_version: int
|
||||||
)
|
)
|
||||||
|
|
||||||
type NotImplemented (
|
type NotImplemented (
|
||||||
|
|
|
@ -2,6 +2,8 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"text/tabwriter"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/containers/libpod/cmd/podman/formats"
|
"github.com/containers/libpod/cmd/podman/formats"
|
||||||
|
@ -26,20 +28,22 @@ func versionCmd(c *cli.Context) error {
|
||||||
default:
|
default:
|
||||||
out = formats.StdoutTemplate{Output: output, Template: versionOutputFormat}
|
out = formats.StdoutTemplate{Output: output, Template: versionOutputFormat}
|
||||||
}
|
}
|
||||||
formats.Writer(out).Out()
|
return formats.Writer(out).Out()
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
fmt.Println("Version: ", output.Version)
|
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
|
||||||
fmt.Println("Go Version: ", output.GoVersion)
|
defer w.Flush()
|
||||||
|
fmt.Fprintf(w, "Version:\t%s\n", output.Version)
|
||||||
|
fmt.Fprintf(w, "RemoteAPI Version:\t%d\n", output.RemoteAPIVersion)
|
||||||
|
fmt.Fprintf(w, "Go Version:\t%s\n", output.GoVersion)
|
||||||
if output.GitCommit != "" {
|
if output.GitCommit != "" {
|
||||||
fmt.Println("Git Commit: ", output.GitCommit)
|
fmt.Fprintf(w, "Git Commit:\t%s\n", output.GitCommit)
|
||||||
}
|
}
|
||||||
// Prints out the build time in readable format
|
// Prints out the build time in readable format
|
||||||
if output.Built != 0 {
|
if output.Built != 0 {
|
||||||
fmt.Println("Built: ", time.Unix(output.Built, 0).Format(time.ANSIC))
|
fmt.Fprintf(w, "Built:\t%s\n", time.Unix(output.Built, 0).Format(time.ANSIC))
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("OS/Arch: ", output.OsArch)
|
fmt.Fprintf(w, "OS/Arch:\t%s\n", output.OsArch)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,11 +19,12 @@ var (
|
||||||
|
|
||||||
//Version is an output struct for varlink
|
//Version is an output struct for varlink
|
||||||
type Version struct {
|
type Version struct {
|
||||||
Version string
|
RemoteAPIVersion int64
|
||||||
GoVersion string
|
Version string
|
||||||
GitCommit string
|
GoVersion string
|
||||||
Built int64
|
GitCommit string
|
||||||
OsArch string
|
Built int64
|
||||||
|
OsArch string
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetVersion returns a VersionOutput struct for varlink and podman
|
// GetVersion returns a VersionOutput struct for varlink and podman
|
||||||
|
@ -39,10 +40,11 @@ func GetVersion() (Version, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Version{
|
return Version{
|
||||||
Version: podmanVersion.Version,
|
RemoteAPIVersion: podmanVersion.RemoteAPIVersion,
|
||||||
GoVersion: runtime.Version(),
|
Version: podmanVersion.Version,
|
||||||
GitCommit: gitCommit,
|
GoVersion: runtime.Version(),
|
||||||
Built: buildTime,
|
GitCommit: gitCommit,
|
||||||
OsArch: runtime.GOOS + "/" + runtime.GOARCH,
|
Built: buildTime,
|
||||||
|
OsArch: runtime.GOOS + "/" + runtime.GOARCH,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,11 +16,12 @@ func (i *LibpodAPI) GetVersion(call iopodman.VarlinkCall) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
return call.ReplyGetVersion(iopodman.Version{
|
return call.ReplyGetVersion(iopodman.Version{
|
||||||
Version: versionInfo.Version,
|
Remote_api_version: versionInfo.RemoteAPIVersion,
|
||||||
Go_version: versionInfo.GoVersion,
|
Version: versionInfo.Version,
|
||||||
Git_commit: versionInfo.GitCommit,
|
Go_version: versionInfo.GoVersion,
|
||||||
Built: versionInfo.Built,
|
Git_commit: versionInfo.GitCommit,
|
||||||
Os_arch: versionInfo.OsArch,
|
Built: versionInfo.Built,
|
||||||
|
Os_arch: versionInfo.OsArch,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
// +build !remoteclient
|
|
||||||
|
|
||||||
package integration
|
package integration
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
@ -5,3 +5,8 @@ package version
|
||||||
// of the top-level README.md file when this is
|
// of the top-level README.md file when this is
|
||||||
// bumped.
|
// bumped.
|
||||||
const Version = "1.0.1-dev"
|
const Version = "1.0.1-dev"
|
||||||
|
|
||||||
|
// RemoteAPIVersion is the version for the remote
|
||||||
|
// client API. It is used to determine compatibility
|
||||||
|
// between a remote podman client and its backend
|
||||||
|
const RemoteAPIVersion = 1
|
||||||
|
|
Loading…
Reference in New Issue