From 16ed0baf65f5aa06530fcb3f8b0ccbdf309aedd1 Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Thu, 22 Feb 2018 14:51:48 -0500 Subject: Move Hostname accessor to more logical place Signed-off-by: Matthew Heon Closes: #386 Approved by: baude --- libpod/container.go | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'libpod/container.go') diff --git a/libpod/container.go b/libpod/container.go index 831e4e886..0e3b8b17f 100644 --- a/libpod/container.go +++ b/libpod/container.go @@ -466,6 +466,21 @@ func (c *Container) RuntimeName() string { return c.runtime.ociRuntime.name } +// Runtime spec accessors +// Unlocked + +// Hostname gets the container's hostname +func (c *Container) Hostname() string { + if c.config.Spec.Hostname != "" { + return c.config.Spec.Hostname + } + + if len(c.ID()) < 11 { + return c.ID() + } + return c.ID()[:12] +} + // State Accessors // Require locking @@ -643,15 +658,3 @@ func (c *Container) RWSize() (int64, error) { } return c.rwSize() } - -// Hostname gets the container's hostname -func (c *Container) Hostname() string { - if c.config.Spec.Hostname != "" { - return c.config.Spec.Hostname - } - - if len(c.ID()) < 11 { - return c.ID() - } - return c.ID()[:12] -} -- cgit v1.2.3-54-g00ecf