mirror of
https://github.com/containers/podman.git
synced 2025-06-19 16:33:24 +08:00
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 <lars@karlitski.net>
This commit is contained in:
@ -8,7 +8,7 @@ type Version (
|
|||||||
version: string,
|
version: string,
|
||||||
go_version: string,
|
go_version: string,
|
||||||
git_commit: string,
|
git_commit: string,
|
||||||
built: int,
|
built: string, # as RFC3339
|
||||||
os_arch: string,
|
os_arch: string,
|
||||||
remote_api_version: int
|
remote_api_version: int
|
||||||
)
|
)
|
||||||
@ -40,7 +40,7 @@ type ImageInList (
|
|||||||
parentId: string,
|
parentId: string,
|
||||||
repoTags: []string,
|
repoTags: []string,
|
||||||
repoDigests: []string,
|
repoDigests: []string,
|
||||||
created: string,
|
created: string, # as RFC3339
|
||||||
size: int,
|
size: int,
|
||||||
virtualSize: int,
|
virtualSize: int,
|
||||||
containers: int,
|
containers: int,
|
||||||
@ -51,7 +51,7 @@ type ImageInList (
|
|||||||
# ImageHistory describes the returned structure from ImageHistory.
|
# ImageHistory describes the returned structure from ImageHistory.
|
||||||
type ImageHistory (
|
type ImageHistory (
|
||||||
id: string,
|
id: string,
|
||||||
created: string,
|
created: string, # as RFC3339
|
||||||
createdBy: string,
|
createdBy: string,
|
||||||
tags: []string,
|
tags: []string,
|
||||||
size: int,
|
size: int,
|
||||||
@ -74,7 +74,7 @@ type ListContainerData (
|
|||||||
image: string,
|
image: string,
|
||||||
imageid: string,
|
imageid: string,
|
||||||
command: []string,
|
command: []string,
|
||||||
createdat: string,
|
createdat: string, # as RFC3339
|
||||||
runningfor: string,
|
runningfor: string,
|
||||||
status: string,
|
status: string,
|
||||||
ports: []ContainerPortMappings,
|
ports: []ContainerPortMappings,
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
@ -113,7 +112,7 @@ func (r *LocalRuntime) GetImages() ([]*ContainerImage, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func imageInListToContainerImage(i iopodman.ImageInList, name string, runtime *LocalRuntime) (*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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -182,12 +181,6 @@ func (r *LocalRuntime) New(ctx context.Context, name, signaturePolicyPath, authf
|
|||||||
return newImage, nil
|
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
|
// 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
|
// the parent of any other layer in store. Double check that image with that
|
||||||
// layer exists as well.
|
// layer exists as well.
|
||||||
@ -251,7 +244,7 @@ func (ci *ContainerImage) History(ctx context.Context) ([]*image.History, error)
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for _, h := range reply {
|
for _, h := range reply {
|
||||||
created, err := splitStringDate(h.Created)
|
created, err := time.ParseInLocation(time.RFC3339, h.Created, time.UTC)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ func (i *LibpodAPI) ListImages(call iopodman.VarlinkCall) error {
|
|||||||
ParentId: image.Parent,
|
ParentId: image.Parent,
|
||||||
RepoTags: image.Names(),
|
RepoTags: image.Names(),
|
||||||
RepoDigests: repoDigests,
|
RepoDigests: repoDigests,
|
||||||
Created: image.Created().String(),
|
Created: image.Created().Format(time.RFC3339),
|
||||||
Size: int64(*size),
|
Size: int64(*size),
|
||||||
VirtualSize: image.VirtualSize,
|
VirtualSize: image.VirtualSize,
|
||||||
Containers: int64(len(containers)),
|
Containers: int64(len(containers)),
|
||||||
@ -97,7 +97,7 @@ func (i *LibpodAPI) GetImage(call iopodman.VarlinkCall, name string) error {
|
|||||||
ParentId: newImage.Parent,
|
ParentId: newImage.Parent,
|
||||||
RepoTags: newImage.Names(),
|
RepoTags: newImage.Names(),
|
||||||
RepoDigests: repoDigests,
|
RepoDigests: repoDigests,
|
||||||
Created: newImage.Created().String(),
|
Created: newImage.Created().Format(time.RFC3339),
|
||||||
Size: int64(*size),
|
Size: int64(*size),
|
||||||
VirtualSize: newImage.VirtualSize,
|
VirtualSize: newImage.VirtualSize,
|
||||||
Containers: int64(len(containers)),
|
Containers: int64(len(containers)),
|
||||||
@ -309,7 +309,7 @@ func (i *LibpodAPI) HistoryImage(call iopodman.VarlinkCall, name string) error {
|
|||||||
for _, hist := range history {
|
for _, hist := range history {
|
||||||
imageHistory := iopodman.ImageHistory{
|
imageHistory := iopodman.ImageHistory{
|
||||||
Id: hist.ID,
|
Id: hist.ID,
|
||||||
Created: hist.Created.String(),
|
Created: hist.Created.Format(time.RFC3339),
|
||||||
CreatedBy: hist.CreatedBy,
|
CreatedBy: hist.CreatedBy,
|
||||||
Tags: newImage.Names(),
|
Tags: newImage.Names(),
|
||||||
Size: hist.Size,
|
Size: hist.Size,
|
||||||
|
@ -3,6 +3,7 @@ package varlinkapi
|
|||||||
import (
|
import (
|
||||||
goruntime "runtime"
|
goruntime "runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/containers/libpod/cmd/podman/varlink"
|
"github.com/containers/libpod/cmd/podman/varlink"
|
||||||
"github.com/containers/libpod/libpod"
|
"github.com/containers/libpod/libpod"
|
||||||
@ -20,7 +21,7 @@ func (i *LibpodAPI) GetVersion(call iopodman.VarlinkCall) error {
|
|||||||
Version: versionInfo.Version,
|
Version: versionInfo.Version,
|
||||||
Go_version: versionInfo.GoVersion,
|
Go_version: versionInfo.GoVersion,
|
||||||
Git_commit: versionInfo.GitCommit,
|
Git_commit: versionInfo.GitCommit,
|
||||||
Built: versionInfo.Built,
|
Built: time.Unix(versionInfo.Built, 0).Format(time.RFC3339),
|
||||||
Os_arch: versionInfo.OsArch,
|
Os_arch: versionInfo.OsArch,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ func makeListContainer(containerID string, batchInfo shared.BatchContainerStruct
|
|||||||
Image: batchInfo.ConConfig.RootfsImageName,
|
Image: batchInfo.ConConfig.RootfsImageName,
|
||||||
Imageid: batchInfo.ConConfig.RootfsImageID,
|
Imageid: batchInfo.ConConfig.RootfsImageID,
|
||||||
Command: batchInfo.ConConfig.Spec.Process.Args,
|
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(),
|
Runningfor: time.Since(batchInfo.ConConfig.CreatedTime).String(),
|
||||||
Status: batchInfo.ConState.String(),
|
Status: batchInfo.ConState.String(),
|
||||||
Ports: ports,
|
Ports: ports,
|
||||||
@ -107,7 +107,7 @@ func makeListPod(pod *libpod.Pod, batchInfo shared.PsOptions) (iopodman.ListPodD
|
|||||||
listPodsContainers = append(listPodsContainers, makeListPodContainers(ctr.ID(), batchInfo))
|
listPodsContainers = append(listPodsContainers, makeListPodContainers(ctr.ID(), batchInfo))
|
||||||
}
|
}
|
||||||
listPod := iopodman.ListPodData{
|
listPod := iopodman.ListPodData{
|
||||||
Createdat: pod.CreatedTime().String(),
|
Createdat: pod.CreatedTime().Format(time.RFC3339),
|
||||||
Id: pod.ID(),
|
Id: pod.ID(),
|
||||||
Name: pod.Name(),
|
Name: pod.Name(),
|
||||||
Status: status,
|
Status: status,
|
||||||
|
Reference in New Issue
Block a user