2013-11-25 23:04:57 -05:00
|
|
|
package docker
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
2014-02-13 17:11:39 -05:00
|
|
|
"code.google.com/p/go/src/pkg/archive/tar"
|
2013-11-29 19:20:59 -05:00
|
|
|
"io"
|
2013-11-25 23:04:57 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
func fakeTar() (io.Reader, error) {
|
2013-11-29 19:20:59 -05:00
|
|
|
content := []byte("Hello world!\n")
|
|
|
|
buf := new(bytes.Buffer)
|
|
|
|
tw := tar.NewWriter(buf)
|
|
|
|
for _, name := range []string{"/etc/postgres/postgres.conf", "/etc/passwd", "/var/log/postgres/postgres.conf"} {
|
|
|
|
hdr := new(tar.Header)
|
|
|
|
hdr.Size = int64(len(content))
|
|
|
|
hdr.Name = name
|
|
|
|
if err := tw.WriteHeader(hdr); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
tw.Write([]byte(content))
|
|
|
|
}
|
|
|
|
tw.Close()
|
|
|
|
return buf, nil
|
2013-11-25 23:04:57 -05:00
|
|
|
}
|