Do not modify data structure while building

This will give odd effects if we output the yaml structure into the image.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
This commit is contained in:
Justin Cormack 2017-07-17 15:42:26 +01:00
parent 760521e197
commit 12439d947d

View File

@ -429,19 +429,20 @@ func filesystem(m Moby, tw *tar.Writer, idMap map[string]uint32) error {
return fmt.Errorf("Specified Source and Metadata for file: %s", f.Path)
}
if f.Source != "" {
if len(f.Source) > 2 && f.Source[:2] == "~/" {
f.Source = homeDir() + f.Source[1:]
source := f.Source
if len(source) > 2 && source[:2] == "~/" {
source = homeDir() + source[1:]
}
if f.Optional {
_, err := os.Stat(f.Source)
_, err := os.Stat(source)
if err != nil {
// skip if not found or readable
log.Debugf("Skipping file [%s] as not readable and marked optional", f.Source)
log.Debugf("Skipping file [%s] as not readable and marked optional", source)
continue
}
}
var err error
contents, err = ioutil.ReadFile(f.Source)
contents, err = ioutil.ReadFile(source)
if err != nil {
return err
}