Skip to content

Commit 682e0ec

Browse files
authored
fix: Apply new tags even if no index is created because the image is too small (#17)
1 parent 0d3b6bd commit 682e0ec

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

handler.go

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ var (
2828
)
2929

3030
const (
31-
BuildFailedMessage = "SOCI index build error"
32-
PushFailedMessage = "SOCI index push error"
33-
SkipPushOnEmptyIndexMessage = "Skipping pushing SOCI index as it does not contain any zTOCs"
34-
BuildAndPushSuccessMessage = "Successfully built and pushed SOCI index"
31+
BuildFailedMessage = "SOCI index build error"
32+
PushFailedMessage = "SOCI index push error"
33+
PushOnEmptyIndexMessage = "SOCI index does not contain any zTOCs"
34+
BuildAndPushSuccessMessage = "Successfully built and pushed SOCI index"
3535

3636
artifactsStoreName = "store"
3737
artifactsDbName = "artifacts.db"
@@ -79,8 +79,19 @@ func indexAndPush(ctx context.Context, repo string, tag string, newTags []string
7979
indexDescriptor, err := buildIndex(ctx, dataDir, sociStore, image)
8080
if err != nil {
8181
if err.Error() == ErrEmptyIndex.Error() {
82-
log.Warn(ctx, SkipPushOnEmptyIndexMessage)
83-
return SkipPushOnEmptyIndexMessage, nil
82+
log.Warn(ctx, PushOnEmptyIndexMessage)
83+
84+
// tag when using --new-tag
85+
// the user will be expecting those tags to exist whether or not we created an index
86+
for _, newTag := range newTags {
87+
if newTag != tag {
88+
err = registry.Tag(ctx, *desc, repo, newTag)
89+
if err != nil {
90+
return logAndReturnError(ctx, PushFailedMessage, err)
91+
}
92+
}
93+
}
94+
return PushOnEmptyIndexMessage, nil
8495
}
8596
return logAndReturnError(ctx, BuildFailedMessage, err)
8697
}

0 commit comments

Comments
 (0)