mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 19:13:34 +00:00
chore: parse Created time on container with CreatedTime
This commit is contained in:
@@ -24,6 +24,20 @@ const (
|
|||||||
|
|
||||||
type Container struct {
|
type Container struct {
|
||||||
types.ContainerJSON
|
types.ContainerJSON
|
||||||
|
// created caches the parsed creation time by CreatedTime.
|
||||||
|
created time.Time
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedTime returns the time when the container was created parsed from the Created field.
|
||||||
|
func (c *Container) CreatedTime() time.Time {
|
||||||
|
if c.created.IsZero() {
|
||||||
|
created, err := time.Parse(time.RFC3339Nano, c.Created)
|
||||||
|
if err != nil {
|
||||||
|
return time.Time{}
|
||||||
|
}
|
||||||
|
c.created = created
|
||||||
|
}
|
||||||
|
return c.created
|
||||||
}
|
}
|
||||||
|
|
||||||
// Healthy determines if the container is running and healthy.
|
// Healthy determines if the container is running and healthy.
|
||||||
|
|||||||
Reference in New Issue
Block a user