Skip to content

Commit 69047de

Browse files
authored
fix: push tag if the tag not bound to the existed manifest (#107)
Signed-off-by: chlins <[email protected]>
1 parent 65f9c5e commit 69047de

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

pkg/backend/push.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,18 @@ func pushIfNotExist(ctx context.Context, pb *ProgressBar, prompt string, src sto
131131
}
132132

133133
if exist {
134+
// if the descriptor is the manifest, should check the tag existence as well.
135+
if desc.MediaType == ocispec.MediaTypeImageManifest {
136+
_, _, err := dst.FetchReference(ctx, tag)
137+
if err != nil {
138+
// try to push the tag if error occurred when fetch reference.
139+
if err := dst.Tag(ctx, desc, tag); err != nil {
140+
pb.Abort(desc)
141+
return fmt.Errorf("failed to push tag to remote: %w", err)
142+
}
143+
}
144+
}
145+
134146
pb.PrintMessage(prompt, desc, "skipped: already exists")
135147
return nil
136148
}

0 commit comments

Comments
 (0)