summaryrefslogtreecommitdiff
path: root/libpod/container_internal.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-03-05 14:28:30 -0800
committerGitHub <noreply@github.com>2019-03-05 14:28:30 -0800
commit40f78439459d0899de8643661b8e996a1e2460d6 (patch)
treed250a49bb2735739c73ee521855c064fa5c6effd /libpod/container_internal.go
parent3d441b5d962308372e4eba85428ac479bc140199 (diff)
parent6c8f2072aaa3e0b46b2f8d94331fcc88ec6bff11 (diff)
downloadpodman-40f78439459d0899de8643661b8e996a1e2460d6.tar.gz
podman-40f78439459d0899de8643661b8e996a1e2460d6.tar.bz2
podman-40f78439459d0899de8643661b8e996a1e2460d6.zip
Merge pull request #2518 from haircommander/pod_host
Append hosts to dependency container's /etc/hosts file
Diffstat (limited to 'libpod/container_internal.go')
-rw-r--r--libpod/container_internal.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/libpod/container_internal.go b/libpod/container_internal.go
index e3753d825..08945c410 100644
--- a/libpod/container_internal.go
+++ b/libpod/container_internal.go
@@ -1231,6 +1231,23 @@ func (c *Container) writeStringToRundir(destFile, output string) (string, error)
return filepath.Join(c.state.DestinationRunDir, destFile), nil
}
+// appendStringToRundir appends the provided string to the runtimedir file
+func (c *Container) appendStringToRundir(destFile, output string) (string, error) {
+ destFileName := filepath.Join(c.state.RunDir, destFile)
+
+ f, err := os.OpenFile(destFileName, os.O_APPEND|os.O_WRONLY, 0600)
+ if err != nil {
+ return "", errors.Wrapf(err, "unable to open %s", destFileName)
+ }
+ defer f.Close()
+
+ if _, err := f.WriteString(output); err != nil {
+ return "", errors.Wrapf(err, "unable to write %s", destFileName)
+ }
+
+ return filepath.Join(c.state.DestinationRunDir, destFile), nil
+}
+
// Save OCI spec to disk, replacing any existing specs for the container
func (c *Container) saveSpec(spec *spec.Spec) error {
// If the OCI spec already exists, we need to replace it