aboutsummaryrefslogtreecommitdiff
path: root/libpod/container.go
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@gmail.com>2018-02-22 14:49:35 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2018-02-23 04:25:47 +0000
commiteafbe76ebee7fa2b2452078d7e9c938421e28f5e (patch)
tree2bda0b57f1cd280449b690dbb6e3f612868150ed /libpod/container.go
parent8eadc208e15023d9fa92cf08ff03c29ac55bf183 (diff)
downloadpodman-eafbe76ebee7fa2b2452078d7e9c938421e28f5e.tar.gz
podman-eafbe76ebee7fa2b2452078d7e9c938421e28f5e.tar.bz2
podman-eafbe76ebee7fa2b2452078d7e9c938421e28f5e.zip
Refactor spec generation in libpod into a function
Signed-off-by: Matthew Heon <matthew.heon@gmail.com> Closes: #386 Approved by: baude
Diffstat (limited to 'libpod/container.go')
-rw-r--r--libpod/container.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/libpod/container.go b/libpod/container.go
index 57b894b26..831e4e886 100644
--- a/libpod/container.go
+++ b/libpod/container.go
@@ -643,3 +643,15 @@ 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]
+}