99cd23cefd
This reverts commit98fc09128b
in order to keep registry v2 schema1 handling and libtrust-key-based engine ID. Because registry v2 schema1 was not officially deprecated and registries are still relying on it, this patch puts its logic back. However, registry v1 relics are not added back since v1 logic has been removed a while ago. This also fixes an engine upgrade issue in a swarm cluster. It was relying on the Engine ID to be the same upon upgrade, but the mentioned commit modified the logic to use UUID and from a different file. Since the libtrust key is always needed to support v2 schema1 pushes, that the old engine ID is based on the libtrust key, and that the engine ID needs to be conserved across upgrades, adding a UUID-based engine ID logic seems to add more complexity than it solves the problems. Hence reverting the engine ID changes as well. Signed-off-by: Tibor Vass <tibor@docker.com> (cherry picked from commitf695e98cb7
) Signed-off-by: Tibor Vass <tibor@docker.com>
66 lines
2 KiB
Go
66 lines
2 KiB
Go
package images // import "github.com/docker/docker/daemon/images"
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
"time"
|
|
|
|
"github.com/docker/distribution/manifest/schema2"
|
|
"github.com/docker/distribution/reference"
|
|
"github.com/docker/docker/api/types"
|
|
"github.com/docker/docker/distribution"
|
|
progressutils "github.com/docker/docker/distribution/utils"
|
|
"github.com/docker/docker/pkg/progress"
|
|
)
|
|
|
|
// PushImage initiates a push operation on the repository named localName.
|
|
func (i *ImageService) PushImage(ctx context.Context, image, tag string, metaHeaders map[string][]string, authConfig *types.AuthConfig, outStream io.Writer) error {
|
|
start := time.Now()
|
|
ref, err := reference.ParseNormalizedNamed(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: i.registryService,
|
|
ImageEventLogger: i.LogImageEvent,
|
|
MetadataStore: i.distributionMetadataStore,
|
|
ImageStore: distribution.NewImageConfigStoreFromStore(i.imageStore),
|
|
ReferenceStore: i.referenceStore,
|
|
},
|
|
ConfigMediaType: schema2.MediaTypeImageConfig,
|
|
LayerStores: distribution.NewLayerProvidersFromStores(i.layerStores),
|
|
TrustKey: i.trustKey,
|
|
UploadManager: i.uploadManager,
|
|
}
|
|
|
|
err = distribution.Push(ctx, ref, imagePushConfig)
|
|
close(progressChan)
|
|
<-writesDone
|
|
imageActions.WithValues("push").UpdateSince(start)
|
|
return err
|
|
}
|