Browse code

Rename LazyContext to LazySource.

Signed-off-by: Daniel Nephin <dnephin@docker.com>

Daniel Nephin authored on 2017/05/26 05:02:29
Showing 5 changed files
... ...
@@ -155,7 +155,7 @@ func (o *copier) calcCopyInfo(origPath string, allowWildcards bool) ([]copyInfo,
155 155
 		var err error
156 156
 		o.source, err = imageSource.Source()
157 157
 		if err != nil {
158
-			return nil, errors.Wrapf(err, "failed to copy")
158
+			return nil, errors.Wrapf(err, "failed to copy from %s", imageSource.ImageID())
159 159
 		}
160 160
 	}
161 161
 
... ...
@@ -359,7 +359,7 @@ func downloadSource(output io.Writer, stdout io.Writer, srcURL string) (remote b
359 359
 		return
360 360
 	}
361 361
 
362
-	lc, err := remotecontext.NewLazyContext(tmpDir)
362
+	lc, err := remotecontext.NewLazySource(tmpDir)
363 363
 	return lc, filename, err
364 364
 }
365 365
 
... ...
@@ -383,7 +383,7 @@ func copyFile(dest copyInfo, source copyInfo, options copyFileOptions) error {
383 383
 
384 384
 	src, err := os.Stat(srcPath)
385 385
 	if err != nil {
386
-		return err // TODO: errors.Wrapf
386
+		return errors.Wrapf(err, "source path not found")
387 387
 	}
388 388
 	if src.IsDir() {
389 389
 		if err := archiver.CopyWithTar(srcPath, destPath); err != nil {
... ...
@@ -156,7 +156,7 @@ func (im *imageMount) Source() (builder.Source, error) {
156 156
 		if err != nil {
157 157
 			return nil, errors.Wrapf(err, "failed to mount %s", im.image.ImageID())
158 158
 		}
159
-		source, err := remotecontext.NewLazyContext(mountPath)
159
+		source, err := remotecontext.NewLazySource(mountPath)
160 160
 		if err != nil {
161 161
 			return nil, errors.Wrapf(err, "failed to create lazycontext for %s", mountPath)
162 162
 		}
... ...
@@ -100,7 +100,7 @@ func (b *Builder) performCopy(state *dispatchState, inst copyInstruction) error
100 100
 	}
101 101
 	destSource, err := imageMount.Source()
102 102
 	if err != nil {
103
-		return err
103
+		return errors.Wrapf(err, "failed to mount copy source")
104 104
 	}
105 105
 
106 106
 	destInfo := newCopyInfoFromSource(destSource, dest, "")
... ...
@@ -81,7 +81,7 @@ func withDockerfileFromContext(c modifiableContext, dockerfilePath string) (buil
81 81
 }
82 82
 
83 83
 func newGitRemote(gitURL string, dockerfilePath string) (builder.Source, *parser.Result, error) {
84
-	c, err := MakeGitContext(gitURL) // TODO: change this to NewLazyContext
84
+	c, err := MakeGitContext(gitURL) // TODO: change this to NewLazySource
85 85
 	if err != nil {
86 86
 		return nil, nil, err
87 87
 	}
... ...
@@ -12,30 +12,30 @@ import (
12 12
 	"github.com/pkg/errors"
13 13
 )
14 14
 
15
-// NewLazyContext creates a new LazyContext. LazyContext defines a hashed build
15
+// NewLazySource creates a new LazyContext. LazyContext defines a hashed build
16 16
 // context based on a root directory. Individual files are hashed first time
17 17
 // they are asked. It is not safe to call methods of LazyContext concurrently.
18
-func NewLazyContext(root string) (builder.Source, error) {
19
-	return &lazyContext{
18
+func NewLazySource(root string) (builder.Source, error) {
19
+	return &lazySource{
20 20
 		root: root,
21 21
 		sums: make(map[string]string),
22 22
 	}, nil
23 23
 }
24 24
 
25
-type lazyContext struct {
25
+type lazySource struct {
26 26
 	root string
27 27
 	sums map[string]string
28 28
 }
29 29
 
30
-func (c *lazyContext) Root() string {
30
+func (c *lazySource) Root() string {
31 31
 	return c.root
32 32
 }
33 33
 
34
-func (c *lazyContext) Close() error {
34
+func (c *lazySource) Close() error {
35 35
 	return nil
36 36
 }
37 37
 
38
-func (c *lazyContext) Hash(path string) (string, error) {
38
+func (c *lazySource) Hash(path string) (string, error) {
39 39
 	cleanPath, fullPath, err := normalize(path, c.root)
40 40
 	if err != nil {
41 41
 		return "", err
... ...
@@ -62,7 +62,7 @@ func (c *lazyContext) Hash(path string) (string, error) {
62 62
 	return sum, nil
63 63
 }
64 64
 
65
-func (c *lazyContext) prepareHash(relPath string, fi os.FileInfo) (string, error) {
65
+func (c *lazySource) prepareHash(relPath string, fi os.FileInfo) (string, error) {
66 66
 	p := filepath.Join(c.root, relPath)
67 67
 	h, err := NewFileHash(p, relPath, fi)
68 68
 	if err != nil {