Make WriteStringToRundir internal

We don't want this in our public API - better to let us control
what gets put in container storage and where.

Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #462
Approved by: baude
This commit is contained in:
Matthew Heon
2018-03-07 11:17:42 -05:00
committed by Atomic Bot
parent d23b9fd4ed
commit 221a3ab2b5

View File

@@ -414,8 +414,8 @@ func (c *Container) cleanupStorage() error {
return c.save()
}
// WriteStringToRundir copies the provided file to the runtimedir
func (c *Container) WriteStringToRundir(destFile, output string) (string, error) {
// writeStringToRundir copies the provided file to the runtimedir
func (c *Container) writeStringToRundir(destFile, output string) (string, error) {
destFileName := filepath.Join(c.state.RunDir, destFile)
f, err := os.Create(destFileName)
if err != nil {
@@ -455,7 +455,7 @@ func (c *Container) generateResolvConf() (string, error) {
return "", errors.Wrapf(err, "unable to read %s", resolvPath)
}
if len(c.config.DNSServer) == 0 && len(c.config.DNSSearch) == 0 && len(c.config.DNSOption) == 0 {
return c.WriteStringToRundir("resolv.conf", fmt.Sprintf("%s", orig))
return c.writeStringToRundir("resolv.conf", fmt.Sprintf("%s", orig))
}
// Read and organize the hosts /etc/resolv.conf
@@ -483,7 +483,7 @@ func (c *Container) generateResolvConf() (string, error) {
resolv.options = nil
resolv.options = append(resolv.options, c.Config().DNSOption...)
}
return c.WriteStringToRundir("resolv.conf", resolv.ToString())
return c.writeStringToRundir("resolv.conf", resolv.ToString())
}
// createResolv creates a resolv struct from an input string
@@ -546,12 +546,12 @@ func (c *Container) generateHosts() (string, error) {
hosts += fmt.Sprintf("%s %s\n", fields[0], fields[1])
}
}
return c.WriteStringToRundir("hosts", hosts)
return c.writeStringToRundir("hosts", hosts)
}
// generateEtcHostname creates a containers /etc/hostname
func (c *Container) generateEtcHostname(hostname string) (string, error) {
return c.WriteStringToRundir("hostname", hostname)
return c.writeStringToRundir("hostname", hostname)
}
// Generate spec for a container