From 6a7139eeeccdb8fc1b015bc0e13be02429f4cde1 Mon Sep 17 00:00:00 2001 From: Martin Zihlmann Date: Thu, 29 May 2025 23:43:04 +0100 Subject: [PATCH] simplify logic for detecting empty layers --- pkg/executor/build.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/executor/build.go b/pkg/executor/build.go index 8e1743267..e95317ca5 100644 --- a/pkg/executor/build.go +++ b/pkg/executor/build.go @@ -416,9 +416,9 @@ func (s *stageBuilder) build() error { if isCacheCommand { v := command.(commands.Cached) layer := v.Layer() - if (files != nil || layer == nil) && len(files) == 0 { - // a cache image with a layer with no files indicates that no files were changed, ie. by 'RUN echo hello' - // a cache image without a layer indicates that no files were changed too, ie. by 'WORKDIR /' + if layer == nil || (files != nil && len(files) == 0) { + // a cache image without a layer indicates that no files were changed, ie. by 'WORKDIR /' + // a cache image with a layer with no files indicates that no files were changed too, ie. by 'RUN echo hello' logrus.Info("No files were changed, appending empty layer to config. No layer added to image.") } else { if err := s.saveLayerToImage(layer, command.String()); err != nil {