From 608019b65b2fb3dc1c88efcbed1cd88b70794fd7 Mon Sep 17 00:00:00 2001 From: Lars Karlitski Date: Mon, 4 Feb 2019 18:18:31 +0100 Subject: varlink: Remove the Ping() method There are other ways for developers to "ensure their varlink setup is working", for example by calling `GetVersion()` or any call on the org.varlink.service interface. Signed-off-by: Lars Karlitski --- pkg/varlinkapi/system.go | 8 -------- 1 file changed, 8 deletions(-) (limited to 'pkg/varlinkapi/system.go') diff --git a/pkg/varlinkapi/system.go b/pkg/varlinkapi/system.go index 376502f21..0c063cee9 100644 --- a/pkg/varlinkapi/system.go +++ b/pkg/varlinkapi/system.go @@ -25,14 +25,6 @@ func (i *LibpodAPI) GetVersion(call iopodman.VarlinkCall) error { }) } -// Ping returns a simple string "OK" response for clients to make sure -// the service is working. -func (i *LibpodAPI) Ping(call iopodman.VarlinkCall) error { - return call.ReplyPing(iopodman.StringResponse{ - Message: "OK", - }) -} - // GetInfo returns details about the podman host and its stores func (i *LibpodAPI) GetInfo(call iopodman.VarlinkCall) error { versionInfo, err := libpod.GetVersion() -- cgit v1.2.3-54-g00ecf From 29392b77e90b59e6f7b7d78db78c9c0ae045bc06 Mon Sep 17 00:00:00 2001 From: Lars Karlitski Date: Mon, 4 Feb 2019 18:56:41 +0100 Subject: varlink: Return all times in RFC 3339 format This is more consistent and eaiser to parse than the format that golang's time.String() returns. Fixes #2260 Signed-off-by: Lars Karlitski --- cmd/podman/varlink/io.podman.varlink | 8 ++++---- libpod/adapter/runtime_remote.go | 11 ++--------- pkg/varlinkapi/images.go | 6 +++--- pkg/varlinkapi/system.go | 3 ++- pkg/varlinkapi/util.go | 4 ++-- 5 files changed, 13 insertions(+), 19 deletions(-) (limited to 'pkg/varlinkapi/system.go') diff --git a/cmd/podman/varlink/io.podman.varlink b/cmd/podman/varlink/io.podman.varlink index deb3b31eb..29c993dd6 100644 --- a/cmd/podman/varlink/io.podman.varlink +++ b/cmd/podman/varlink/io.podman.varlink @@ -8,7 +8,7 @@ type Version ( version: string, go_version: string, git_commit: string, - built: int, + built: string, # as RFC3339 os_arch: string, remote_api_version: int ) @@ -40,7 +40,7 @@ type ImageInList ( parentId: string, repoTags: []string, repoDigests: []string, - created: string, + created: string, # as RFC3339 size: int, virtualSize: int, containers: int, @@ -51,7 +51,7 @@ type ImageInList ( # ImageHistory describes the returned structure from ImageHistory. type ImageHistory ( id: string, - created: string, + created: string, # as RFC3339 createdBy: string, tags: []string, size: int, @@ -74,7 +74,7 @@ type ListContainerData ( image: string, imageid: string, command: []string, - createdat: string, + createdat: string, # as RFC3339 runningfor: string, status: string, ports: []ContainerPortMappings, diff --git a/libpod/adapter/runtime_remote.go b/libpod/adapter/runtime_remote.go index 4dfae34e1..644802909 100644 --- a/libpod/adapter/runtime_remote.go +++ b/libpod/adapter/runtime_remote.go @@ -6,7 +6,6 @@ import ( "bufio" "context" "encoding/json" - "fmt" "github.com/pkg/errors" "io" "os" @@ -113,7 +112,7 @@ func (r *LocalRuntime) GetImages() ([]*ContainerImage, error) { } func imageInListToContainerImage(i iopodman.ImageInList, name string, runtime *LocalRuntime) (*ContainerImage, error) { - created, err := splitStringDate(i.Created) + created, err := time.ParseInLocation(time.RFC3339, i.Created, time.UTC) if err != nil { return nil, err } @@ -182,12 +181,6 @@ func (r *LocalRuntime) New(ctx context.Context, name, signaturePolicyPath, authf return newImage, nil } -func splitStringDate(d string) (time.Time, error) { - fields := strings.Fields(d) - t := fmt.Sprintf("%sT%sZ", fields[0], fields[1]) - return time.ParseInLocation(time.RFC3339Nano, t, time.UTC) -} - // IsParent goes through the layers in the store and checks if i.TopLayer is // the parent of any other layer in store. Double check that image with that // layer exists as well. @@ -251,7 +244,7 @@ func (ci *ContainerImage) History(ctx context.Context) ([]*image.History, error) return nil, err } for _, h := range reply { - created, err := splitStringDate(h.Created) + created, err := time.ParseInLocation(time.RFC3339, h.Created, time.UTC) if err != nil { return nil, err } diff --git a/pkg/varlinkapi/images.go b/pkg/varlinkapi/images.go index 6463d9edb..ecf4d331c 100644 --- a/pkg/varlinkapi/images.go +++ b/pkg/varlinkapi/images.go @@ -57,7 +57,7 @@ func (i *LibpodAPI) ListImages(call iopodman.VarlinkCall) error { ParentId: image.Parent, RepoTags: image.Names(), RepoDigests: repoDigests, - Created: image.Created().String(), + Created: image.Created().Format(time.RFC3339), Size: int64(*size), VirtualSize: image.VirtualSize, Containers: int64(len(containers)), @@ -97,7 +97,7 @@ func (i *LibpodAPI) GetImage(call iopodman.VarlinkCall, name string) error { ParentId: newImage.Parent, RepoTags: newImage.Names(), RepoDigests: repoDigests, - Created: newImage.Created().String(), + Created: newImage.Created().Format(time.RFC3339), Size: int64(*size), VirtualSize: newImage.VirtualSize, Containers: int64(len(containers)), @@ -309,7 +309,7 @@ func (i *LibpodAPI) HistoryImage(call iopodman.VarlinkCall, name string) error { for _, hist := range history { imageHistory := iopodman.ImageHistory{ Id: hist.ID, - Created: hist.Created.String(), + Created: hist.Created.Format(time.RFC3339), CreatedBy: hist.CreatedBy, Tags: newImage.Names(), Size: hist.Size, diff --git a/pkg/varlinkapi/system.go b/pkg/varlinkapi/system.go index 0c063cee9..a64dc4217 100644 --- a/pkg/varlinkapi/system.go +++ b/pkg/varlinkapi/system.go @@ -3,6 +3,7 @@ package varlinkapi import ( goruntime "runtime" "strings" + "time" "github.com/containers/libpod/cmd/podman/varlink" "github.com/containers/libpod/libpod" @@ -20,7 +21,7 @@ func (i *LibpodAPI) GetVersion(call iopodman.VarlinkCall) error { Version: versionInfo.Version, Go_version: versionInfo.GoVersion, Git_commit: versionInfo.GitCommit, - Built: versionInfo.Built, + Built: time.Unix(versionInfo.Built, 0).Format(time.RFC3339), Os_arch: versionInfo.OsArch, }) } diff --git a/pkg/varlinkapi/util.go b/pkg/varlinkapi/util.go index a80c8db41..51891e729 100644 --- a/pkg/varlinkapi/util.go +++ b/pkg/varlinkapi/util.go @@ -61,7 +61,7 @@ func makeListContainer(containerID string, batchInfo shared.BatchContainerStruct Image: batchInfo.ConConfig.RootfsImageName, Imageid: batchInfo.ConConfig.RootfsImageID, Command: batchInfo.ConConfig.Spec.Process.Args, - Createdat: batchInfo.ConConfig.CreatedTime.String(), + Createdat: batchInfo.ConConfig.CreatedTime.Format(time.RFC3339), Runningfor: time.Since(batchInfo.ConConfig.CreatedTime).String(), Status: batchInfo.ConState.String(), Ports: ports, @@ -107,7 +107,7 @@ func makeListPod(pod *libpod.Pod, batchInfo shared.PsOptions) (iopodman.ListPodD listPodsContainers = append(listPodsContainers, makeListPodContainers(ctr.ID(), batchInfo)) } listPod := iopodman.ListPodData{ - Createdat: pod.CreatedTime().String(), + Createdat: pod.CreatedTime().Format(time.RFC3339), Id: pod.ID(), Name: pod.Name(), Status: status, -- cgit v1.2.3-54-g00ecf From 27baf9970e1267f4ad48692a4465e7b61310af4a Mon Sep 17 00:00:00 2001 From: Lars Karlitski Date: Mon, 4 Feb 2019 19:04:08 +0100 Subject: varlink: Simplify GetVersion() call Not having the `Version` wrapper type makes it easier for clients to work with the returned data. Signed-off-by: Lars Karlitski --- cmd/podman/varlink/io.podman.varlink | 22 +++++++++------------- pkg/varlinkapi/system.go | 16 ++++++++-------- 2 files changed, 17 insertions(+), 21 deletions(-) (limited to 'pkg/varlinkapi/system.go') diff --git a/cmd/podman/varlink/io.podman.varlink b/cmd/podman/varlink/io.podman.varlink index 29c993dd6..51f0592dd 100644 --- a/cmd/podman/varlink/io.podman.varlink +++ b/cmd/podman/varlink/io.podman.varlink @@ -3,16 +3,6 @@ interface io.podman -# Version is the structure returned by GetVersion -type Version ( - version: string, - go_version: string, - git_commit: string, - built: string, # as RFC3339 - os_arch: string, - remote_api_version: int -) - # ContainerChanges describes the return struct for ListContainerChanges type ContainerChanges ( changed: []string, @@ -399,9 +389,15 @@ type Runlabel( opts: [string]string ) -# GetVersion returns a Version structure describing the libpod setup on their -# system. -method GetVersion() -> (version: Version) +# GetVersion returns version and build information of the podman service +method GetVersion() -> ( + version: string, + go_version: string, + git_commit: string, + built: string, # as RFC3339 + os_arch: string, + remote_api_version: int +) # GetInfo returns a [PodmanInfo](#PodmanInfo) struct that describes podman and its host such as storage stats, # build information of Podman, and system-wide registries. diff --git a/pkg/varlinkapi/system.go b/pkg/varlinkapi/system.go index a64dc4217..3f32615ec 100644 --- a/pkg/varlinkapi/system.go +++ b/pkg/varlinkapi/system.go @@ -16,14 +16,14 @@ func (i *LibpodAPI) GetVersion(call iopodman.VarlinkCall) error { return err } - return call.ReplyGetVersion(iopodman.Version{ - Remote_api_version: versionInfo.RemoteAPIVersion, - Version: versionInfo.Version, - Go_version: versionInfo.GoVersion, - Git_commit: versionInfo.GitCommit, - Built: time.Unix(versionInfo.Built, 0).Format(time.RFC3339), - Os_arch: versionInfo.OsArch, - }) + return call.ReplyGetVersion( + versionInfo.Version, + versionInfo.GoVersion, + versionInfo.GitCommit, + time.Unix(versionInfo.Built, 0).Format(time.RFC3339), + versionInfo.OsArch, + versionInfo.RemoteAPIVersion, + ) } // GetInfo returns details about the podman host and its stores -- cgit v1.2.3-54-g00ecf