From a9528bdab66a6c8dfa26b00a29cd6e4f2e8a81a8 Mon Sep 17 00:00:00 2001 From: Alberto Carretero Date: Mon, 16 Sep 2024 18:53:09 +0200 Subject: [PATCH] tidy up --- internal/slicer/slicer.go | 34 +++++++++++++++++----------------- internal/slicer/slicer_test.go | 2 +- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/internal/slicer/slicer.go b/internal/slicer/slicer.go index 21ebda53..fb3c6406 100644 --- a/internal/slicer/slicer.go +++ b/internal/slicer/slicer.go @@ -451,13 +451,13 @@ func generateManifests(options *generateManifestsOptions) error { // Nothing to do. return nil } - jsonwallw := jsonwall.NewDBWriter(&jsonwall.DBWriterOptions{ + dbw := jsonwall.NewDBWriter(&jsonwall.DBWriterOptions{ Schema: manifest.Schema, }) // Add packages to the manifest. for _, info := range options.packageInfo { - err := jsonwallw.Add(&manifest.Package{ + err := dbw.Add(&manifest.Package{ Kind: "package", Name: info.Name, Version: info.Version, @@ -470,7 +470,7 @@ func generateManifests(options *generateManifestsOptions) error { } // Add slices to the manifest. for _, s := range options.selection { - err := jsonwallw.Add(&manifest.Slice{ + err := dbw.Add(&manifest.Slice{ Kind: "slice", Name: s.String(), }) @@ -481,19 +481,19 @@ func generateManifests(options *generateManifestsOptions) error { // Add paths and contents to the manifest. for _, entry := range options.report.Entries { sliceNames := []string{} - for s := range entry.Slices { - err := jsonwallw.Add(&manifest.Content{ + for slice := range entry.Slices { + err := dbw.Add(&manifest.Content{ Kind: "content", - Slice: s.String(), + Slice: slice.String(), Path: entry.Path, }) if err != nil { return err } - sliceNames = append(sliceNames, s.String()) + sliceNames = append(sliceNames, slice.String()) } sort.Strings(sliceNames) - err := jsonwallw.Add(&manifest.Path{ + err := dbw.Add(&manifest.Path{ Kind: "path", Path: entry.Path, Mode: fmt.Sprintf("0%o", unixPerm(entry.Mode)), @@ -510,19 +510,19 @@ func generateManifests(options *generateManifestsOptions) error { // Add the manifest path and content entries to the manifest. for path, slices := range manifestSlices { sliceNames := []string{} - for _, s := range slices { - err := jsonwallw.Add(&manifest.Content{ + for _, slice := range slices { + err := dbw.Add(&manifest.Content{ Kind: "content", - Slice: s.String(), + Slice: slice.String(), Path: path, }) if err != nil { return err } - sliceNames = append(sliceNames, s.String()) + sliceNames = append(sliceNames, slice.String()) } sort.Strings(sliceNames) - err := jsonwallw.Add(&manifest.Path{ + err := dbw.Add(&manifest.Path{ Kind: "path", Path: path, Mode: fmt.Sprintf("0%o", unixPerm(ManifestMode)), @@ -552,7 +552,7 @@ func generateManifests(options *generateManifestsOptions) error { return err } defer w.Close() - _, err = jsonwallw.WriteTo(w) + _, err = dbw.WriteTo(w) return err } @@ -568,12 +568,12 @@ func unixPerm(mode fs.FileMode) (perm uint32) { // returns a map from the manifest path to all the slices that declare it. func locateManifestSlices(slices []*setup.Slice) (map[string][]*setup.Slice, error) { manifestSlices := make(map[string][]*setup.Slice) - for _, s := range slices { - for path, info := range s.Contents { + for _, slice := range slices { + for path, info := range slice.Contents { if info.Generate == setup.GenerateManifest { dir := strings.TrimSuffix(path, "**") path = filepath.Join(dir, ManifestFileName) - manifestSlices[path] = append(manifestSlices[path], s) + manifestSlices[path] = append(manifestSlices[path], slice) } } } diff --git a/internal/slicer/slicer_test.go b/internal/slicer/slicer_test.go index c532ed34..50aaae5f 100644 --- a/internal/slicer/slicer_test.go +++ b/internal/slicer/slicer_test.go @@ -247,8 +247,8 @@ var slicerTests = []slicerTest{{ summary: "Copyright is installed", slices: []setup.SliceKey{{"test-package", "myslice"}}, pkgs: map[string]testutil.TestPackage{ - // Add the copyright entries to the package. "test-package": { + // Add the copyright entries to the package. Data: testutil.MustMakeDeb(append(testutil.TestPackageEntries, testPackageCopyrightEntries...)), }, },