add dry-run support for publish command

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
This commit is contained in:
Guillaume Lours 2023-10-05 11:31:56 -07:00 committed by Nicolas De loof
parent a345515f91
commit 2c0b023273

View File

@ -102,12 +102,13 @@ func (s *composeService) publish(ctx context.Context, project *types.Project, re
Digest: digest.FromBytes(emptyConfig),
Size: int64(len(emptyConfig)),
}
var imageManifest []byte
if !s.dryRun {
err = resolver.Push(ctx, named, configDescriptor, emptyConfig)
if err != nil {
return err
}
imageManifest, err := json.Marshal(v1.Manifest{
imageManifest, err = json.Marshal(v1.Manifest{
Versioned: specs.Versioned{SchemaVersion: 2},
MediaType: v1.MediaTypeImageManifest,
ArtifactType: "application/vnd.docker.compose.project",
@ -117,13 +118,14 @@ func (s *composeService) publish(ctx context.Context, project *types.Project, re
if err != nil {
return err
}
}
w.Event(progress.Event{
ID: repository,
Text: "publishing",
Status: progress.Working,
})
if !s.dryRun {
err = resolver.Push(ctx, named, v1.Descriptor{
MediaType: v1.MediaTypeImageManifest,
Digest: digest.FromString(string(imageManifest)),
@ -141,6 +143,7 @@ func (s *composeService) publish(ctx context.Context, project *types.Project, re
})
return err
}
}
w.Event(progress.Event{
ID: repository,
Text: "published",