mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Rename LazyContext to LazySource.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
parent
bd5f92d263
commit
ecd44d23cc
5 changed files with 14 additions and 14 deletions
|
@ -155,7 +155,7 @@ func (o *copier) calcCopyInfo(origPath string, allowWildcards bool) ([]copyInfo,
|
||||||
var err error
|
var err error
|
||||||
o.source, err = imageSource.Source()
|
o.source, err = imageSource.Source()
|
||||||
if err != nil {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
lc, err := remotecontext.NewLazyContext(tmpDir)
|
lc, err := remotecontext.NewLazySource(tmpDir)
|
||||||
return lc, filename, err
|
return lc, filename, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -383,7 +383,7 @@ func copyFile(dest copyInfo, source copyInfo, options copyFileOptions) error {
|
||||||
|
|
||||||
src, err := os.Stat(srcPath)
|
src, err := os.Stat(srcPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err // TODO: errors.Wrapf
|
return errors.Wrapf(err, "source path not found")
|
||||||
}
|
}
|
||||||
if src.IsDir() {
|
if src.IsDir() {
|
||||||
if err := archiver.CopyWithTar(srcPath, destPath); err != nil {
|
if err := archiver.CopyWithTar(srcPath, destPath); err != nil {
|
||||||
|
|
|
@ -156,7 +156,7 @@ func (im *imageMount) Source() (builder.Source, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(err, "failed to mount %s", im.image.ImageID())
|
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 {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(err, "failed to create lazycontext for %s", mountPath)
|
return nil, errors.Wrapf(err, "failed to create lazycontext for %s", mountPath)
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,7 @@ func (b *Builder) performCopy(state *dispatchState, inst copyInstruction) error
|
||||||
}
|
}
|
||||||
destSource, err := imageMount.Source()
|
destSource, err := imageMount.Source()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return errors.Wrapf(err, "failed to mount copy source")
|
||||||
}
|
}
|
||||||
|
|
||||||
destInfo := newCopyInfoFromSource(destSource, dest, "")
|
destInfo := newCopyInfoFromSource(destSource, dest, "")
|
||||||
|
|
|
@ -81,7 +81,7 @@ func withDockerfileFromContext(c modifiableContext, dockerfilePath string) (buil
|
||||||
}
|
}
|
||||||
|
|
||||||
func newGitRemote(gitURL string, dockerfilePath string) (builder.Source, *parser.Result, error) {
|
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 {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,30 +12,30 @@ import (
|
||||||
"github.com/pkg/errors"
|
"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
|
// 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.
|
// they are asked. It is not safe to call methods of LazyContext concurrently.
|
||||||
func NewLazyContext(root string) (builder.Source, error) {
|
func NewLazySource(root string) (builder.Source, error) {
|
||||||
return &lazyContext{
|
return &lazySource{
|
||||||
root: root,
|
root: root,
|
||||||
sums: make(map[string]string),
|
sums: make(map[string]string),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type lazyContext struct {
|
type lazySource struct {
|
||||||
root string
|
root string
|
||||||
sums map[string]string
|
sums map[string]string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *lazyContext) Root() string {
|
func (c *lazySource) Root() string {
|
||||||
return c.root
|
return c.root
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *lazyContext) Close() error {
|
func (c *lazySource) Close() error {
|
||||||
return nil
|
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)
|
cleanPath, fullPath, err := normalize(path, c.root)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
@ -62,7 +62,7 @@ func (c *lazyContext) Hash(path string) (string, error) {
|
||||||
return sum, nil
|
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)
|
p := filepath.Join(c.root, relPath)
|
||||||
h, err := NewFileHash(p, relPath, fi)
|
h, err := NewFileHash(p, relPath, fi)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue