diff options
author | baude <bbaude@redhat.com> | 2018-03-26 09:39:14 -0500 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-04-23 14:29:45 +0000 |
commit | 8493dba23c73617d9529b7ca13b400d50ac6f455 (patch) | |
tree | c0de0c67334b9fa7166e01cae95dc560c1e2455a /cmd/podman | |
parent | cf1d884ffa45b342f38a78189bbd86186ce6cbfe (diff) | |
download | podman-8493dba23c73617d9529b7ca13b400d50ac6f455.tar.gz podman-8493dba23c73617d9529b7ca13b400d50ac6f455.tar.bz2 podman-8493dba23c73617d9529b7ca13b400d50ac6f455.zip |
Initial varlink implementation
Signed-off-by: baude <bbaude@redhat.com>
Closes: #627
Approved by: mheon
Diffstat (limited to 'cmd/podman')
-rw-r--r-- | cmd/podman/info.go | 2 | ||||
-rw-r--r-- | cmd/podman/ioprojectatomicpodman/generate.go | 3 | ||||
-rw-r--r-- | cmd/podman/ioprojectatomicpodman/io.projectatomic.podman.varlink | 65 | ||||
-rw-r--r-- | cmd/podman/main.go | 1 | ||||
-rw-r--r-- | cmd/podman/varlink.go | 60 | ||||
-rw-r--r-- | cmd/podman/version.go | 39 |
6 files changed, 144 insertions, 26 deletions
diff --git a/cmd/podman/info.go b/cmd/podman/info.go index 89f32a258..1c4ba2515 100644 --- a/cmd/podman/info.go +++ b/cmd/podman/info.go @@ -79,6 +79,6 @@ func debugInfo(c *cli.Context) map[string]interface{} { info["compiler"] = runtime.Compiler info["go version"] = runtime.Version() info["podman version"] = c.App.Version - info["git commit"] = gitCommit + info["git commit"] = libpod.GitCommit return info } diff --git a/cmd/podman/ioprojectatomicpodman/generate.go b/cmd/podman/ioprojectatomicpodman/generate.go new file mode 100644 index 000000000..b24234f0a --- /dev/null +++ b/cmd/podman/ioprojectatomicpodman/generate.go @@ -0,0 +1,3 @@ +package ioprojectatomicpodman + +//go:generate $GOPATH/bin/varlink-go-interface-generator io.projectatomic.podman.varlink diff --git a/cmd/podman/ioprojectatomicpodman/io.projectatomic.podman.varlink b/cmd/podman/ioprojectatomicpodman/io.projectatomic.podman.varlink new file mode 100644 index 000000000..00a99017c --- /dev/null +++ b/cmd/podman/ioprojectatomicpodman/io.projectatomic.podman.varlink @@ -0,0 +1,65 @@ +# Podman Service Interface +interface io.projectatomic.podman + +type Version ( + version: string, + go_version: string, + git_commit: string, + built: int, + os_arch: string +) + +type NotImplemented ( + comment: string +) + +type StringResponse ( + message: string +) + +# System +method Ping() -> (ping: StringResponse) +method GetVersion() -> (version: Version) + +# Containers +method ListContainers() -> (notimplemented: NotImplemented) +method CreateContainer() -> (notimplemented: NotImplemented) +method InspectContainer() -> (notimplemented: NotImplemented) +method ListContainerProcesses() -> (notimplemented: NotImplemented) +method GetContainerLogs() -> (notimplemented: NotImplemented) +method ListContainerChanges() -> (notimplemented: NotImplemented) +method ExportContainer() -> (notimplemented: NotImplemented) +method GetContainerStats() -> (notimplemented: NotImplemented) +method ResizeContainerTty() -> (notimplemented: NotImplemented) +method StartContainer() -> (notimplemented: NotImplemented) +method StopContainer() -> (notimplemented: NotImplemented) +method RestartContainer() -> (notimplemented: NotImplemented) +method KillContainer() -> (notimplemented: NotImplemented) +method UpdateContainer() -> (notimplemented: NotImplemented) +method RenameContainer() -> (notimplemented: NotImplemented) +method PauseContainer() -> (notimplemented: NotImplemented) +method UnpauseContainer() -> (notimplemented: NotImplemented) +method AttachToContainer() -> (notimplemented: NotImplemented) +method WaitContainer() -> (notimplemented: NotImplemented) +method RemoveContainer() -> (notimplemented: NotImplemented) +method DeleteStoppedContainers() -> (notimplemented: NotImplemented) + +# Images +method ListImages() -> (notimplemented: NotImplemented) +method BuildImage() -> (notimplemented: NotImplemented) +method CreateImage() -> (notimplemented: NotImplemented) +method InspectImage() -> (notimplemented: NotImplemented) +method HistoryImage() -> (notimplemented: NotImplemented) +method PushImage() -> (notimplemented: NotImplemented) +method TagImage() -> (notimplemented: NotImplemented) +method RemoveImage() -> (notimplemented: NotImplemented) +method SearchImage() -> (notimplemented: NotImplemented) +method DeleteUnusedImages() -> (notimplemented: NotImplemented) +method CreateFromContainer() -> (notimplemented: NotImplemented) +method ImportImage() -> (notimplemented: NotImplemented) +method ExportImage() -> (notimplemented: NotImplemented) +method PullImage() -> (notimplemented: NotImplemented) + + +# Something failed +error ActionFailed (reason: string) diff --git a/cmd/podman/main.go b/cmd/podman/main.go index ef11f7905..a283c2622 100644 --- a/cmd/podman/main.go +++ b/cmd/podman/main.go @@ -70,6 +70,7 @@ func main() { topCommand, umountCommand, unpauseCommand, + varlinkCommand, versionCommand, waitCommand, } diff --git a/cmd/podman/varlink.go b/cmd/podman/varlink.go new file mode 100644 index 000000000..75ddc6c4d --- /dev/null +++ b/cmd/podman/varlink.go @@ -0,0 +1,60 @@ +package main + +import ( + "github.com/pkg/errors" + "github.com/projectatomic/libpod/cmd/podman/ioprojectatomicpodman" + "github.com/projectatomic/libpod/pkg/varlinkapi" + "github.com/projectatomic/libpod/version" + "github.com/urfave/cli" + "github.com/varlink/go/varlink" +) + +var ( + varlinkDescription = ` + podman varlink + + run varlink interface +` + varlinkFlags = []cli.Flag{} + varlinkCommand = cli.Command{ + Name: "varlink", + Usage: "Run varlink interface", + Description: varlinkDescription, + Flags: varlinkFlags, + Action: varlinkCmd, + ArgsUsage: "VARLINK_URI", + } +) + +func varlinkCmd(c *cli.Context) error { + args := c.Args() + if len(args) < 1 { + return errors.Errorf("you must provide a varlink URI") + } + + var varlinkInterfaces = []*ioprojectatomicpodman.VarlinkInterface{varlinkapi.VarlinkLibpod} + // Register varlink service. The metadata can be retrieved with: + // $ varlink info [varlink address URI] + service, err := varlink.NewService( + "Atomic", + "podman", + version.Version, + "https://github.com/projectatomic/libpod", + ) + if err != nil { + return errors.Wrapf(err, "unable to create new varlink service") + } + + for _, i := range varlinkInterfaces { + if err := service.RegisterInterface(i); err != nil { + return errors.Errorf("unable to register varlink interface %v", i) + } + } + + // Run the varlink server at the given address + if err = service.Listen(args[0], 0); err != nil { + return errors.Errorf("unable to start varlink service") + } + + return nil +} diff --git a/cmd/podman/version.go b/cmd/podman/version.go index be9b406e7..952cf32d3 100644 --- a/cmd/podman/version.go +++ b/cmd/podman/version.go @@ -2,41 +2,30 @@ package main import ( "fmt" - "runtime" - "strconv" "time" + "github.com/pkg/errors" + "github.com/projectatomic/libpod/libpod" "github.com/urfave/cli" ) -// Overwritten at build time -var ( - // gitCommit is the commit that the binary is being built from. - // It will be populated by the Makefile. - gitCommit string - // buildInfo is the time at which the binary was built - // It will be populated by the Makefile. - buildInfo string -) - // versionCmd gets and prints version info for version command func versionCmd(c *cli.Context) error { - fmt.Println("Version: ", c.App.Version) - fmt.Println("Go Version: ", runtime.Version()) - if gitCommit != "" { - fmt.Println("Git Commit: ", gitCommit) + output, err := libpod.GetVersion() + if err != nil { + errors.Wrapf(err, "unable to determine version") + } + fmt.Println("Version: ", output.Version) + fmt.Println("Go Version: ", output.GoVersion) + if output.GitCommit != "" { + fmt.Println("Git Commit: ", output.GitCommit) } - if buildInfo != "" { - // Converts unix time from string to int64 - buildTime, err := strconv.ParseInt(buildInfo, 10, 64) - if err != nil { - return err - } - // Prints out the build time in readable format - fmt.Println("Built: ", time.Unix(buildTime, 0).Format(time.ANSIC)) + // Prints out the build time in readable format + if libpod.BuildInfo != "" { + fmt.Println("Built: ", time.Unix(output.Built, 0).Format(time.ANSIC)) } - fmt.Println("OS/Arch: ", runtime.GOOS+"/"+runtime.GOARCH) + fmt.Println("OS/Arch: ", output.OsArch) return nil } |