mirror of
				https://github.com/moby/moby.git
				synced 2022-11-09 12:21:53 -05:00 
			
		
		
		
	Support layers from external URLs
This is used to support downloading Windows base images from Microsoft servers. Signed-off-by: John Starks <jostarks@microsoft.com>
This commit is contained in:
		
							parent
							
								
									9c902364fb
								
							
						
					
					
						commit
						05bd04350b
					
				
					 16 changed files with 231 additions and 53 deletions
				
			
		| 
						 | 
				
			
			@ -7,6 +7,7 @@ import (
 | 
			
		|||
	"time"
 | 
			
		||||
 | 
			
		||||
	"github.com/Sirupsen/logrus"
 | 
			
		||||
	"github.com/docker/distribution"
 | 
			
		||||
	"github.com/docker/docker/image"
 | 
			
		||||
	"github.com/docker/docker/layer"
 | 
			
		||||
	"github.com/docker/docker/pkg/archive"
 | 
			
		||||
| 
						 | 
				
			
			@ -318,7 +319,11 @@ func (ldm *LayerDownloadManager) makeDownloadFunc(descriptor DownloadDescriptor,
 | 
			
		|||
				return
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			d.layer, err = d.layerStore.Register(inflatedLayerData, parentLayer)
 | 
			
		||||
			var src *distribution.Descriptor
 | 
			
		||||
			if fs, ok := descriptor.(layer.ForeignSourcer); ok {
 | 
			
		||||
				src = fs.ForeignSource()
 | 
			
		||||
			}
 | 
			
		||||
			d.layer, err = d.layerStore.RegisterForeign(inflatedLayerData, parentLayer, src)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				select {
 | 
			
		||||
				case <-d.Transfer.Context().Done():
 | 
			
		||||
| 
						 | 
				
			
			@ -409,7 +414,11 @@ func (ldm *LayerDownloadManager) makeDownloadFuncFromDownload(descriptor Downloa
 | 
			
		|||
			}
 | 
			
		||||
			defer layerReader.Close()
 | 
			
		||||
 | 
			
		||||
			d.layer, err = d.layerStore.Register(layerReader, parentLayer)
 | 
			
		||||
			var src *distribution.Descriptor
 | 
			
		||||
			if fs, ok := l.(layer.ForeignSourcer); ok {
 | 
			
		||||
				src = fs.ForeignSource()
 | 
			
		||||
			}
 | 
			
		||||
			d.layer, err = d.layerStore.RegisterForeign(layerReader, parentLayer, src)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				d.err = fmt.Errorf("failed to register layer: %v", err)
 | 
			
		||||
				return
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -10,6 +10,7 @@ import (
 | 
			
		|||
	"testing"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	"github.com/docker/distribution"
 | 
			
		||||
	"github.com/docker/distribution/digest"
 | 
			
		||||
	"github.com/docker/docker/image"
 | 
			
		||||
	"github.com/docker/docker/layer"
 | 
			
		||||
| 
						 | 
				
			
			@ -71,6 +72,10 @@ func createChainIDFromParent(parent layer.ChainID, dgsts ...layer.DiffID) layer.
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
func (ls *mockLayerStore) Register(reader io.Reader, parentID layer.ChainID) (layer.Layer, error) {
 | 
			
		||||
	return ls.RegisterForeign(reader, parentID, nil)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (ls *mockLayerStore) RegisterForeign(reader io.Reader, parentID layer.ChainID, _ *distribution.Descriptor) (layer.Layer, error) {
 | 
			
		||||
	var (
 | 
			
		||||
		parent layer.Layer
 | 
			
		||||
		err    error
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue