dont append layer if known empty

This commit is contained in:
Martin Zihlmann 2025-05-27 22:42:36 +01:00
parent 1d2bff5959
commit bf9e24bf48
No known key found for this signature in database
GPG Key ID: 0F7784F41354DE99
1 changed files with 8 additions and 4 deletions

View File

@ -398,10 +398,14 @@ func (s *stageBuilder) build() error {
continue continue
} }
if isCacheCommand { if isCacheCommand {
v := command.(commands.Cached) if files != nil && len(files) == 0 {
layer := v.Layer() logrus.Info("No files were changed, appending empty layer to config. No layer added to image.")
if err := s.saveLayerToImage(layer, command.String()); err != nil { } else {
return errors.Wrap(err, "failed to save layer") v := command.(commands.Cached)
layer := v.Layer()
if err := s.saveLayerToImage(layer, command.String()); err != nil {
return errors.Wrap(err, "failed to save layer")
}
} }
} else { } else {
tarPath, err := s.takeSnapshot(files, command.ShouldDetectDeletedFiles()) tarPath, err := s.takeSnapshot(files, command.ShouldDetectDeletedFiles())