Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
tests: reimplemented "WriteFile"
Browse files Browse the repository at this point in the history
  • Loading branch information
kayrus committed Mar 17, 2016
1 parent 8ea4155 commit cfbb3fc
Showing 1 changed file with 27 additions and 13 deletions.
40 changes: 27 additions & 13 deletions functional/platform/nspawn.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,19 +376,33 @@ UseDNS no
return
}

if err = ioutil.WriteFile(path.Join(fsdir, "/etc/passwd"), []byte("core:x:500:500:CoreOS Admin:/home/core:/bin/bash"), 0644); err != nil {
log.Printf("Failed writing /etc/passwd: %v", err)
return
}

if err = ioutil.WriteFile(path.Join(fsdir, "/etc/group"), []byte("core:x:500:"), 0644); err != nil {
log.Printf("Failed writing /etc/group: %v", err)
return
}

if err = ioutil.WriteFile(path.Join(fsdir, "/home/core/.bash_profile"), []byte("export PATH=/opt/fleet:$PATH"), 0644); err != nil {
log.Printf("Failed writing /home/core/.bash_profile: %v", err)
return
filesContents := []struct {
path string
contents string
mode os.FileMode
}{
{
"/etc/passwd",
"core:x:500:500:CoreOS Admin:/home/core:/bin/bash",
0644,
},
{
"/etc/group",
"core:x:500:",
0644,
},
{
"/home/core/.bash_profile",
"export PATH=/opt/fleet:$PATH",
0644,
},
}

for _, file := range filesContents {
if err = ioutil.WriteFile(path.Join(fsdir, file.path), []byte(file.contents), file.mode); err != nil {
log.Printf("Failed writing %s: %v", path.Join(fsdir, file.path), err)
return
}
}

if err = nc.insertBin(fleetdBinPath, fsdir); err != nil {
Expand Down

0 comments on commit cfbb3fc

Please sign in to comment.