From ee83c936d4d10520d102409bdca10227d7d945d2 Mon Sep 17 00:00:00 2001 From: Alberto Carretero Date: Fri, 30 Aug 2024 16:49:28 +0200 Subject: [PATCH] bugfix: proper until calculation for content created outside packages --- internal/slicer/slicer.go | 9 ++++++++- internal/slicer/slicer_test.go | 24 ++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/internal/slicer/slicer.go b/internal/slicer/slicer.go index 16efaef5..1271effd 100644 --- a/internal/slicer/slicer.go +++ b/internal/slicer/slicer.go @@ -264,8 +264,15 @@ func Run(options *RunOptions) error { } } for relPath, slices := range relPaths { - // All the pathInfo(s) are equivalent because of conflict validation. + until := setup.UntilMutate + for _, slice := range slices { + if slice.Contents[relPath].Until == setup.UntilNone { + until = setup.UntilNone + break + } + } pathInfo := slices[0].Contents[relPath] + pathInfo.Until = until data := pathData{ until: pathInfo.Until, mutable: pathInfo.Mutable, diff --git a/internal/slicer/slicer_test.go b/internal/slicer/slicer_test.go index 4d31fc5b..29dee89e 100644 --- a/internal/slicer/slicer_test.go +++ b/internal/slicer/slicer_test.go @@ -1037,6 +1037,30 @@ var slicerTests = []slicerTest{{ }, filesystem: map[string]string{}, manifestPaths: map[string]string{}, +}, { + summary: "Content not created in packages with until:mutate on one and reading from script", + slices: []setup.SliceKey{ + {"test-package", "myslice1"}, + {"test-package", "myslice2"}, + }, + release: map[string]string{ + "slices/mydir/test-package.yaml": ` + package: test-package + slices: + myslice1: + contents: + /file: {text: foo, until: mutate} + mutate: | + content.read("/file") + myslice2: + contents: + /file: {text: foo} + mutate: | + content.read("/file") + `, + }, + filesystem: map[string]string{"/file": "file 0644 2c26b46b"}, + manifestPaths: map[string]string{"/file": "file 0644 2c26b46b {test-package_myslice1,test-package_myslice2}"}, }, { summary: "Install two packages, both are recorded", slices: []setup.SliceKey{