From 54f32f2cc024090c3f284f7b0b6832f2b19a6660 Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Wed, 7 Mar 2018 14:10:19 -0500 Subject: Convert bind mounts to use DB field Refactors creation of bind mounts into a separate function that can be called from elsewhere (e.g. pod start or container restart). This function stores the mounts in the DB using the field established last commit. Spec generation now relies upon this field in the DB instead of manually enumerating files to be bind mounted in. Signed-off-by: Matthew Heon Closes: #462 Approved by: baude --- libpod/container_inspect.go | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'libpod/container_inspect.go') diff --git a/libpod/container_inspect.go b/libpod/container_inspect.go index 3a1728826..bbfcd4446 100644 --- a/libpod/container_inspect.go +++ b/libpod/container_inspect.go @@ -25,6 +25,25 @@ func (c *Container) getContainerInspectData(size bool, driverData *inspect.Data) execIDs = append(execIDs, id) } + if c.state.BindMounts == nil { + c.state.BindMounts = make(map[string]string) + } + + resolvPath := "" + if path, ok := c.state.BindMounts["/etc/resolv.conf"]; ok { + resolvPath = path + } + + hostsPath := "" + if path, ok := c.state.BindMounts["/etc/hosts"]; ok { + hostsPath = path + } + + hostnamePath := "" + if path, ok := c.state.BindMounts["/etc/hostname"]; ok { + hostnamePath = path + } + data := &inspect.ContainerInspectData{ ID: config.ID, Created: config.CreatedTime, @@ -45,9 +64,9 @@ func (c *Container) getContainerInspectData(size bool, driverData *inspect.Data) }, ImageID: config.RootfsImageID, ImageName: config.RootfsImageName, - ResolvConfPath: "", // TODO get from networking path - HostnamePath: spec.Annotations["io.kubernetes.cri-o.HostnamePath"], // not sure - HostsPath: "", // can't get yet + ResolvConfPath: resolvPath, + HostnamePath: hostnamePath, + HostsPath: hostsPath, StaticDir: config.StaticDir, LogPath: config.LogPath, Name: config.Name, -- cgit v1.2.3-54-g00ecf