mirror of
https://github.com/containers/podman.git
synced 2025-06-23 10:32:22 +08:00
Merge pull request #2199 from baude/remoteversion
enable podman-remote version
This commit is contained in:
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)
|
||||
|
||||
os_arch [string](https://godoc.org/builtin#string)
|
||||
|
||||
remote_api_version [int](https://godoc.org/builtin#int)
|
||||
## Errors
|
||||
### <a name="ContainerNotFound"></a>type ContainerNotFound
|
||||
|
||||
|
@ -38,7 +38,6 @@ func getAppCommands() []cli.Command {
|
||||
topCommand,
|
||||
umountCommand,
|
||||
unpauseCommand,
|
||||
versionCommand,
|
||||
volumeCommand,
|
||||
waitCommand,
|
||||
}
|
||||
|
@ -1,11 +1,13 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"fmt"
|
||||
rt "runtime"
|
||||
|
||||
"github.com/containers/libpod/cmd/podman/formats"
|
||||
"github.com/containers/libpod/libpod"
|
||||
"github.com/containers/libpod/libpod/adapter"
|
||||
"github.com/containers/libpod/version"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
@ -38,6 +40,7 @@ func infoCmd(c *cli.Context) error {
|
||||
return err
|
||||
}
|
||||
info := map[string]interface{}{}
|
||||
remoteClientInfo := map[string]interface{}{}
|
||||
|
||||
runtime, err := adapter.GetRuntime(c)
|
||||
if err != nil {
|
||||
@ -49,9 +52,13 @@ func infoCmd(c *cli.Context) error {
|
||||
if err != nil {
|
||||
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") {
|
||||
debugInfo := debugInfo(c)
|
||||
infoArr = append(infoArr, libpod.InfoData{Type: "debug", Data: debugInfo})
|
||||
@ -80,8 +87,8 @@ func infoCmd(c *cli.Context) error {
|
||||
// top-level "debug" info
|
||||
func debugInfo(c *cli.Context) map[string]interface{} {
|
||||
info := map[string]interface{}{}
|
||||
info["compiler"] = runtime.Compiler
|
||||
info["go version"] = runtime.Version()
|
||||
info["compiler"] = rt.Compiler
|
||||
info["go version"] = rt.Version()
|
||||
info["podman version"] = c.App.Version
|
||||
version, _ := libpod.GetVersion()
|
||||
info["git commit"] = version.GitCommit
|
||||
|
@ -96,6 +96,7 @@ func main() {
|
||||
pullCommand,
|
||||
rmiCommand,
|
||||
tagCommand,
|
||||
versionCommand,
|
||||
}
|
||||
|
||||
app.Commands = append(app.Commands, getAppCommands()...)
|
||||
|
@ -9,7 +9,8 @@ type Version (
|
||||
go_version: string,
|
||||
git_commit: string,
|
||||
built: int,
|
||||
os_arch: string
|
||||
os_arch: string,
|
||||
remote_api_version: int
|
||||
)
|
||||
|
||||
type NotImplemented (
|
||||
|
@ -2,6 +2,8 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"text/tabwriter"
|
||||
"time"
|
||||
|
||||
"github.com/containers/libpod/cmd/podman/formats"
|
||||
@ -26,20 +28,22 @@ func versionCmd(c *cli.Context) error {
|
||||
default:
|
||||
out = formats.StdoutTemplate{Output: output, Template: versionOutputFormat}
|
||||
}
|
||||
formats.Writer(out).Out()
|
||||
return nil
|
||||
return formats.Writer(out).Out()
|
||||
}
|
||||
fmt.Println("Version: ", output.Version)
|
||||
fmt.Println("Go Version: ", output.GoVersion)
|
||||
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
|
||||
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 != "" {
|
||||
fmt.Println("Git Commit: ", output.GitCommit)
|
||||
fmt.Fprintf(w, "Git Commit:\t%s\n", output.GitCommit)
|
||||
}
|
||||
// Prints out the build time in readable format
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -19,11 +19,12 @@ var (
|
||||
|
||||
//Version is an output struct for varlink
|
||||
type Version struct {
|
||||
Version string
|
||||
GoVersion string
|
||||
GitCommit string
|
||||
Built int64
|
||||
OsArch string
|
||||
RemoteAPIVersion int64
|
||||
Version string
|
||||
GoVersion string
|
||||
GitCommit string
|
||||
Built int64
|
||||
OsArch string
|
||||
}
|
||||
|
||||
// GetVersion returns a VersionOutput struct for varlink and podman
|
||||
@ -39,10 +40,11 @@ func GetVersion() (Version, error) {
|
||||
}
|
||||
}
|
||||
return Version{
|
||||
Version: podmanVersion.Version,
|
||||
GoVersion: runtime.Version(),
|
||||
GitCommit: gitCommit,
|
||||
Built: buildTime,
|
||||
OsArch: runtime.GOOS + "/" + runtime.GOARCH,
|
||||
RemoteAPIVersion: podmanVersion.RemoteAPIVersion,
|
||||
Version: podmanVersion.Version,
|
||||
GoVersion: runtime.Version(),
|
||||
GitCommit: gitCommit,
|
||||
Built: buildTime,
|
||||
OsArch: runtime.GOOS + "/" + runtime.GOARCH,
|
||||
}, nil
|
||||
}
|
||||
|
@ -16,11 +16,12 @@ func (i *LibpodAPI) GetVersion(call iopodman.VarlinkCall) error {
|
||||
}
|
||||
|
||||
return call.ReplyGetVersion(iopodman.Version{
|
||||
Version: versionInfo.Version,
|
||||
Go_version: versionInfo.GoVersion,
|
||||
Git_commit: versionInfo.GitCommit,
|
||||
Built: versionInfo.Built,
|
||||
Os_arch: versionInfo.OsArch,
|
||||
Remote_api_version: versionInfo.RemoteAPIVersion,
|
||||
Version: versionInfo.Version,
|
||||
Go_version: versionInfo.GoVersion,
|
||||
Git_commit: versionInfo.GitCommit,
|
||||
Built: versionInfo.Built,
|
||||
Os_arch: versionInfo.OsArch,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
// +build !remoteclient
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
|
@ -5,3 +5,8 @@ package version
|
||||
// of the top-level README.md file when this is
|
||||
// bumped.
|
||||
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
|
||||
|
Reference in New Issue
Block a user