From 12439d947d40997724f3aa9f26c0c815ae571340 Mon Sep 17 00:00:00 2001 From: Justin Cormack Date: Mon, 17 Jul 2017 15:42:26 +0100 Subject: [PATCH] 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 --- src/moby/build.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/moby/build.go b/src/moby/build.go index 6214de400..9312733ed 100644 --- a/src/moby/build.go +++ b/src/moby/build.go @@ -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 }