From 844504278c74e51d6382cdc857a014cac378e2c0 Mon Sep 17 00:00:00 2001 From: Alberto Carretero Date: Mon, 30 Sep 2024 14:19:40 +0200 Subject: [PATCH] default manifest filename for FindPaths --- internal/manifest/manifest.go | 5 +++-- internal/manifest/manifest_test.go | 10 +++------- internal/slicer/slicer.go | 3 +-- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/internal/manifest/manifest.go b/internal/manifest/manifest.go index e5b198be..3a3129f5 100644 --- a/internal/manifest/manifest.go +++ b/internal/manifest/manifest.go @@ -15,6 +15,7 @@ import ( ) const Schema = "1.0" +const DefaultFilename = "manifest.wall" type Package struct { Kind string `json:"kind"` @@ -165,13 +166,13 @@ func Validate(manifest *Manifest) (err error) { // FindPaths finds the paths marked with "generate:manifest" and // returns a map from the manifest path to all the slices that declare it. -func FindPaths(slices []*setup.Slice, manifestFileName string) map[string][]*setup.Slice { +func FindPaths(slices []*setup.Slice) map[string][]*setup.Slice { manifestSlices := make(map[string][]*setup.Slice) for _, slice := range slices { for path, info := range slice.Contents { if info.Generate == setup.GenerateManifest { dir := strings.TrimSuffix(path, "**") - path = filepath.Join(dir, manifestFileName) + path = filepath.Join(dir, DefaultFilename) manifestSlices[path] = append(manifestSlices[path], slice) } } diff --git a/internal/manifest/manifest_test.go b/internal/manifest/manifest_test.go index 0c163fcf..825fefca 100644 --- a/internal/manifest/manifest_test.go +++ b/internal/manifest/manifest_test.go @@ -176,7 +176,6 @@ func (s *S) TestManifestReadValidate(c *C) { var findPathsTests = []struct { summary string slices []*setup.Slice - filename string expected map[string][]string }{{ summary: "Single slice", @@ -189,7 +188,6 @@ var findPathsTests = []struct { }, }, }}, - filename: "manifest.wall", expected: map[string][]string{ "/folder/manifest.wall": []string{"slice1"}, }, @@ -199,7 +197,6 @@ var findPathsTests = []struct { Name: "slice1", Contents: map[string]setup.PathInfo{}, }}, - filename: "manifest.wall", expected: map[string][]string{}, }, { summary: "Several matches with several groups", @@ -239,10 +236,9 @@ var findPathsTests = []struct { }, }, }}, - filename: "mfest.wall", expected: map[string][]string{ - "/folder/mfest.wall": {"slice1", "slice2"}, - "/other-folder/mfest.wall": {"slice4", "slice5"}, + "/folder/manifest.wall": {"slice1", "slice2"}, + "/other-folder/manifest.wall": {"slice4", "slice5"}, }, }} @@ -250,7 +246,7 @@ func (s *S) TestFindPaths(c *C) { for _, test := range findPathsTests { c.Logf("Summary: %s", test.summary) - manifestSlices := manifest.FindPaths(test.slices, test.filename) + manifestSlices := manifest.FindPaths(test.slices) slicesByName := map[string]*setup.Slice{} for _, slice := range test.slices { diff --git a/internal/slicer/slicer.go b/internal/slicer/slicer.go index c275b301..6188f806 100644 --- a/internal/slicer/slicer.go +++ b/internal/slicer/slicer.go @@ -23,7 +23,6 @@ import ( "github.com/canonical/chisel/internal/setup" ) -const manifestFilename = "manifest.wall" const manifestMode fs.FileMode = 0644 type RunOptions struct { @@ -335,7 +334,7 @@ func Run(options *RunOptions) error { func generateManifests(targetDir string, selection *setup.Selection, report *manifest.Report, pkgInfos []*archive.PackageInfo) error { - manifestSlices := manifest.FindPaths(selection.Slices, manifestFilename) + manifestSlices := manifest.FindPaths(selection.Slices) if len(manifestSlices) == 0 { // Nothing to do. return nil