Rename LazyContext to LazySource.

Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
Daniel Nephin 2017-05-25 16:02:29 -04:00
parent bd5f92d263
commit ecd44d23cc
5 changed files with 14 additions and 14 deletions

View File

@ -155,7 +155,7 @@ func (o *copier) calcCopyInfo(origPath string, allowWildcards bool) ([]copyInfo,
var err error
o.source, err = imageSource.Source()
if err != nil {
return nil, errors.Wrapf(err, "failed to copy")
return nil, errors.Wrapf(err, "failed to copy from %s", imageSource.ImageID())
}
}
@ -359,7 +359,7 @@ func downloadSource(output io.Writer, stdout io.Writer, srcURL string) (remote b
return
}
lc, err := remotecontext.NewLazyContext(tmpDir)
lc, err := remotecontext.NewLazySource(tmpDir)
return lc, filename, err
}
@ -383,7 +383,7 @@ func copyFile(dest copyInfo, source copyInfo, options copyFileOptions) error {
src, err := os.Stat(srcPath)
if err != nil {
return err // TODO: errors.Wrapf
return errors.Wrapf(err, "source path not found")
}
if src.IsDir() {
if err := archiver.CopyWithTar(srcPath, destPath); err != nil {

View File

@ -156,7 +156,7 @@ func (im *imageMount) Source() (builder.Source, error) {
if err != nil {
return nil, errors.Wrapf(err, "failed to mount %s", im.image.ImageID())
}
source, err := remotecontext.NewLazyContext(mountPath)
source, err := remotecontext.NewLazySource(mountPath)
if err != nil {
return nil, errors.Wrapf(err, "failed to create lazycontext for %s", mountPath)
}

View File

@ -100,7 +100,7 @@ func (b *Builder) performCopy(state *dispatchState, inst copyInstruction) error
}
destSource, err := imageMount.Source()
if err != nil {
return err
return errors.Wrapf(err, "failed to mount copy source")
}
destInfo := newCopyInfoFromSource(destSource, dest, "")

View File

@ -81,7 +81,7 @@ func withDockerfileFromContext(c modifiableContext, dockerfilePath string) (buil
}
func newGitRemote(gitURL string, dockerfilePath string) (builder.Source, *parser.Result, error) {
c, err := MakeGitContext(gitURL) // TODO: change this to NewLazyContext
c, err := MakeGitContext(gitURL) // TODO: change this to NewLazySource
if err != nil {
return nil, nil, err
}

View File

@ -12,30 +12,30 @@ import (
"github.com/pkg/errors"
)
// NewLazyContext creates a new LazyContext. LazyContext defines a hashed build
// NewLazySource creates a new LazyContext. LazyContext defines a hashed build
// context based on a root directory. Individual files are hashed first time
// they are asked. It is not safe to call methods of LazyContext concurrently.
func NewLazyContext(root string) (builder.Source, error) {
return &lazyContext{
func NewLazySource(root string) (builder.Source, error) {
return &lazySource{
root: root,
sums: make(map[string]string),
}, nil
}
type lazyContext struct {
type lazySource struct {
root string
sums map[string]string
}
func (c *lazyContext) Root() string {
func (c *lazySource) Root() string {
return c.root
}
func (c *lazyContext) Close() error {
func (c *lazySource) Close() error {
return nil
}
func (c *lazyContext) Hash(path string) (string, error) {
func (c *lazySource) Hash(path string) (string, error) {
cleanPath, fullPath, err := normalize(path, c.root)
if err != nil {
return "", err
@ -62,7 +62,7 @@ func (c *lazyContext) Hash(path string) (string, error) {
return sum, nil
}
func (c *lazyContext) prepareHash(relPath string, fi os.FileInfo) (string, error) {
func (c *lazySource) prepareHash(relPath string, fi os.FileInfo) (string, error) {
p := filepath.Join(c.root, relPath)
h, err := NewFileHash(p, relPath, fi)
if err != nil {