3d86b0c79b
Move plugins to shared distribution stack with images. Create immutable plugin config that matches schema2 requirements. Ensure data being pushed is same as pulled/created. Store distribution artifacts in a blobstore. Run init layer setup for every plugin start. Fix breakouts from unsafe file accesses. Add support for `docker plugin install --alias` Uses normalized references for default names to avoid collisions when using default hosts/tags. Some refactoring of the plugin manager to support the change, like removing the singleton manager and adding manager config struct. Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com> Signed-off-by: Derek McGowan <derek@mcgstyle.net>
63 lines
1.9 KiB
Go
63 lines
1.9 KiB
Go
package daemon
|
|
|
|
import (
|
|
"io"
|
|
|
|
"github.com/docker/distribution/manifest/schema2"
|
|
"github.com/docker/docker/api/types"
|
|
"github.com/docker/docker/distribution"
|
|
progressutils "github.com/docker/docker/distribution/utils"
|
|
"github.com/docker/docker/pkg/progress"
|
|
"github.com/docker/docker/reference"
|
|
"golang.org/x/net/context"
|
|
)
|
|
|
|
// PushImage initiates a push operation on the repository named localName.
|
|
func (daemon *Daemon) PushImage(ctx context.Context, image, tag string, metaHeaders map[string][]string, authConfig *types.AuthConfig, outStream io.Writer) error {
|
|
ref, err := reference.ParseNamed(image)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if tag != "" {
|
|
// Push by digest is not supported, so only tags are supported.
|
|
ref, err = reference.WithTag(ref, tag)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
// Include a buffer so that slow client connections don't affect
|
|
// transfer performance.
|
|
progressChan := make(chan progress.Progress, 100)
|
|
|
|
writesDone := make(chan struct{})
|
|
|
|
ctx, cancelFunc := context.WithCancel(ctx)
|
|
|
|
go func() {
|
|
progressutils.WriteDistributionProgress(cancelFunc, outStream, progressChan)
|
|
close(writesDone)
|
|
}()
|
|
|
|
imagePushConfig := &distribution.ImagePushConfig{
|
|
Config: distribution.Config{
|
|
MetaHeaders: metaHeaders,
|
|
AuthConfig: authConfig,
|
|
ProgressOutput: progress.ChanOutput(progressChan),
|
|
RegistryService: daemon.RegistryService,
|
|
ImageEventLogger: daemon.LogImageEvent,
|
|
MetadataStore: daemon.distributionMetadataStore,
|
|
ImageStore: distribution.NewImageConfigStoreFromStore(daemon.imageStore),
|
|
ReferenceStore: daemon.referenceStore,
|
|
},
|
|
ConfigMediaType: schema2.MediaTypeImageConfig,
|
|
LayerStore: distribution.NewLayerProviderFromStore(daemon.layerStore),
|
|
TrustKey: daemon.trustKey,
|
|
UploadManager: daemon.uploadManager,
|
|
}
|
|
|
|
err = distribution.Push(ctx, ref, imagePushConfig)
|
|
close(progressChan)
|
|
<-writesDone
|
|
return err
|
|
}
|