From 5dedac8cbbc5211cf5d29dcfc16831b03c220bc8 Mon Sep 17 00:00:00 2001 From: Alvaro <1841612+inercia@users.noreply.github.com> Date: Wed, 30 Dec 2020 18:47:37 +0100 Subject: [PATCH] Print the creation time for containers (#431) * Added a new `created` field that exports the creation time for all the containers in the cluster. Signed-off-by: Alvaro Saurin --- pkg/runtimes/docker/translate.go | 3 +-- pkg/types/types.go | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/runtimes/docker/translate.go b/pkg/runtimes/docker/translate.go index 414ff012..f65ec0a8 100644 --- a/pkg/runtimes/docker/translate.go +++ b/pkg/runtimes/docker/translate.go @@ -39,7 +39,6 @@ import ( // TranslateNodeToContainer translates a k3d node specification to a docker container representation func TranslateNodeToContainer(node *k3d.Node) (*NodeInDocker, error) { - /* initialize everything that we need */ containerConfig := docker.Config{} hostConfig := docker.HostConfig{ @@ -134,7 +133,6 @@ func TranslateContainerToNode(cont *types.Container) (*k3d.Node, error) { // TranslateContainerDetailsToNode translates a docker containerJSON object into a k3d node representation func TranslateContainerDetailsToNode(containerDetails types.ContainerJSON) (*k3d.Node, error) { - // translate portMap to string representation ports := []string{} for containerPort, portBindingList := range containerDetails.HostConfig.PortBindings { @@ -201,6 +199,7 @@ func TranslateContainerDetailsToNode(containerDetails types.ContainerJSON) (*k3d Args: []string{}, // empty, since Cmd already contains flags Ports: ports, Restart: restart, + Created: containerDetails.Created, Labels: labels, Network: clusterNetwork, ServerOpts: serverOpts, diff --git a/pkg/types/types.go b/pkg/types/types.go index bf20e6df..654cdf51 100644 --- a/pkg/types/types.go +++ b/pkg/types/types.go @@ -240,6 +240,7 @@ type Node struct { Args []string `yaml:"extra_args" json:"extraArgs,omitempty"` Ports []string `yaml:"port_mappings" json:"portMappings,omitempty"` Restart bool `yaml:"restart" json:"restart,omitempty"` + Created string `yaml:"created" json:"created,omitempty"` Labels map[string]string // filled automatically Network string // filled automatically ExtraHosts []string // filled automatically