From 305c01432bb3451807f430767ed6796433ab3ef3 Mon Sep 17 00:00:00 2001 From: Alberto Carretero Date: Fri, 17 Jan 2025 11:38:52 +0100 Subject: [PATCH] change package names to apache --- cmd/chisel/cmd_cut.go | 6 +- cmd/chisel/cmd_info.go | 6 +- .../testutil => apachetestutil}/manifest.go | 2 +- internal/{apache/util => apacheutil}/log.go | 2 +- .../{apache/util => apacheutil}/suite_test.go | 12 +- internal/{apache/util => apacheutil}/util.go | 2 +- .../{apache/util => apacheutil}/util_test.go | 28 ++-- internal/manifestutil/manifestutil_test.go | 10 +- internal/setup/setup.go | 22 ++-- internal/setup/setup_test.go | 28 ++-- internal/setup/yaml.go | 8 +- internal/slicer/slicer_test.go | 120 +++++++++--------- pkg/manifest/manifest.go | 4 +- pkg/manifest/manifest_test.go | 8 +- 14 files changed, 129 insertions(+), 129 deletions(-) rename internal/{apache/testutil => apachetestutil}/manifest.go (98%) rename internal/{apache/util => apacheutil}/log.go (98%) rename internal/{apache/util => apacheutil}/suite_test.go (56%) rename internal/{apache/util => apacheutil}/util.go (97%) rename internal/{apache/util => apacheutil}/util_test.go (67%) diff --git a/cmd/chisel/cmd_cut.go b/cmd/chisel/cmd_cut.go index f43b2c62..9138fefa 100644 --- a/cmd/chisel/cmd_cut.go +++ b/cmd/chisel/cmd_cut.go @@ -3,7 +3,7 @@ package main import ( "github.com/jessevdk/go-flags" - "github.com/canonical/chisel/internal/apache/util" + "github.com/canonical/chisel/internal/apacheutil" "github.com/canonical/chisel/internal/archive" "github.com/canonical/chisel/internal/cache" "github.com/canonical/chisel/internal/setup" @@ -44,9 +44,9 @@ func (cmd *cmdCut) Execute(args []string) error { return ErrExtraArgs } - sliceKeys := make([]util.SliceKey, len(cmd.Positional.SliceRefs)) + sliceKeys := make([]apacheutil.SliceKey, len(cmd.Positional.SliceRefs)) for i, sliceRef := range cmd.Positional.SliceRefs { - sliceKey, err := util.ParseSliceKey(sliceRef) + sliceKey, err := apacheutil.ParseSliceKey(sliceRef) if err != nil { return err } diff --git a/cmd/chisel/cmd_info.go b/cmd/chisel/cmd_info.go index e6517fe5..416e107f 100644 --- a/cmd/chisel/cmd_info.go +++ b/cmd/chisel/cmd_info.go @@ -8,7 +8,7 @@ import ( "github.com/jessevdk/go-flags" "gopkg.in/yaml.v3" - "github.com/canonical/chisel/internal/apache/util" + "github.com/canonical/chisel/internal/apacheutil" "github.com/canonical/chisel/internal/setup" ) @@ -83,7 +83,7 @@ func selectPackageSlices(release *setup.Release, queries []string) (packages []* pkgSlices := make(map[string][]string) allPkgSlices := make(map[string]bool) - sliceExists := func(key util.SliceKey) bool { + sliceExists := func(key apacheutil.SliceKey) bool { pkg, ok := release.Packages[key.Package] if !ok { return false @@ -94,7 +94,7 @@ func selectPackageSlices(release *setup.Release, queries []string) (packages []* for _, query := range queries { var pkg, slice string if strings.Contains(query, "_") { - key, err := util.ParseSliceKey(query) + key, err := apacheutil.ParseSliceKey(query) if err != nil || !sliceExists(key) { notFound = append(notFound, query) continue diff --git a/internal/apache/testutil/manifest.go b/internal/apachetestutil/manifest.go similarity index 98% rename from internal/apache/testutil/manifest.go rename to internal/apachetestutil/manifest.go index 5ef40a4d..5631f856 100644 --- a/internal/apache/testutil/manifest.go +++ b/internal/apachetestutil/manifest.go @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 -package testutil +package apachetestutil import ( "gopkg.in/check.v1" diff --git a/internal/apache/util/log.go b/internal/apacheutil/log.go similarity index 98% rename from internal/apache/util/log.go rename to internal/apacheutil/log.go index 85d43e69..c4404181 100644 --- a/internal/apache/util/log.go +++ b/internal/apacheutil/log.go @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 -package util +package apacheutil import ( "fmt" diff --git a/internal/apache/util/suite_test.go b/internal/apacheutil/suite_test.go similarity index 56% rename from internal/apache/util/suite_test.go rename to internal/apacheutil/suite_test.go index c1ed8a71..50c664f5 100644 --- a/internal/apache/util/suite_test.go +++ b/internal/apacheutil/suite_test.go @@ -1,13 +1,13 @@ // SPDX-License-Identifier: Apache-2.0 -package util_test +package apacheutil_test import ( "testing" . "gopkg.in/check.v1" - "github.com/canonical/chisel/internal/apache/util" + "github.com/canonical/chisel/internal/apacheutil" ) func Test(t *testing.T) { TestingT(t) } @@ -17,11 +17,11 @@ type S struct{} var _ = Suite(&S{}) func (s *S) SetUpTest(c *C) { - util.SetDebug(true) - util.SetLogger(c) + apacheutil.SetDebug(true) + apacheutil.SetLogger(c) } func (s *S) TearDownTest(c *C) { - util.SetDebug(false) - util.SetLogger(nil) + apacheutil.SetDebug(false) + apacheutil.SetLogger(nil) } diff --git a/internal/apache/util/util.go b/internal/apacheutil/util.go similarity index 97% rename from internal/apache/util/util.go rename to internal/apacheutil/util.go index b94bf966..7e0f8e6d 100644 --- a/internal/apache/util/util.go +++ b/internal/apacheutil/util.go @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 -package util +package apacheutil import ( "fmt" diff --git a/internal/apache/util/util_test.go b/internal/apacheutil/util_test.go similarity index 67% rename from internal/apache/util/util_test.go rename to internal/apacheutil/util_test.go index ff18da4c..6289473c 100644 --- a/internal/apache/util/util_test.go +++ b/internal/apacheutil/util_test.go @@ -1,47 +1,47 @@ // SPDX-License-Identifier: Apache-2.0 -package util_test +package apacheutil_test import ( . "gopkg.in/check.v1" - "github.com/canonical/chisel/internal/apache/util" + "github.com/canonical/chisel/internal/apacheutil" ) var sliceKeyTests = []struct { input string - expected util.SliceKey + expected apacheutil.SliceKey err string }{{ input: "foo_bar", - expected: util.SliceKey{Package: "foo", Slice: "bar"}, + expected: apacheutil.SliceKey{Package: "foo", Slice: "bar"}, }, { input: "fo_bar", - expected: util.SliceKey{Package: "fo", Slice: "bar"}, + expected: apacheutil.SliceKey{Package: "fo", Slice: "bar"}, }, { input: "1234_bar", - expected: util.SliceKey{Package: "1234", Slice: "bar"}, + expected: apacheutil.SliceKey{Package: "1234", Slice: "bar"}, }, { input: "foo1.1-2-3_bar", - expected: util.SliceKey{Package: "foo1.1-2-3", Slice: "bar"}, + expected: apacheutil.SliceKey{Package: "foo1.1-2-3", Slice: "bar"}, }, { input: "foo-pkg_dashed-slice-name", - expected: util.SliceKey{Package: "foo-pkg", Slice: "dashed-slice-name"}, + expected: apacheutil.SliceKey{Package: "foo-pkg", Slice: "dashed-slice-name"}, }, { input: "foo+_bar", - expected: util.SliceKey{Package: "foo+", Slice: "bar"}, + expected: apacheutil.SliceKey{Package: "foo+", Slice: "bar"}, }, { input: "foo_slice123", - expected: util.SliceKey{Package: "foo", Slice: "slice123"}, + expected: apacheutil.SliceKey{Package: "foo", Slice: "slice123"}, }, { input: "g++_bins", - expected: util.SliceKey{Package: "g++", Slice: "bins"}, + expected: apacheutil.SliceKey{Package: "g++", Slice: "bins"}, }, { input: "a+_bar", - expected: util.SliceKey{Package: "a+", Slice: "bar"}, + expected: apacheutil.SliceKey{Package: "a+", Slice: "bar"}, }, { input: "a._bar", - expected: util.SliceKey{Package: "a.", Slice: "bar"}, + expected: apacheutil.SliceKey{Package: "a.", Slice: "bar"}, }, { input: "foo_ba", err: `invalid slice reference: "foo_ba"`, @@ -85,7 +85,7 @@ var sliceKeyTests = []struct { func (s *S) TestParseSliceKey(c *C) { for _, test := range sliceKeyTests { - key, err := util.ParseSliceKey(test.input) + key, err := apacheutil.ParseSliceKey(test.input) if test.err != "" { c.Assert(err, ErrorMatches, test.err) continue diff --git a/internal/manifestutil/manifestutil_test.go b/internal/manifestutil/manifestutil_test.go index bc6af2ab..42510576 100644 --- a/internal/manifestutil/manifestutil_test.go +++ b/internal/manifestutil/manifestutil_test.go @@ -7,7 +7,7 @@ import ( . "gopkg.in/check.v1" - "github.com/canonical/chisel/internal/apache/testutil" + "github.com/canonical/chisel/internal/apachetestutil" "github.com/canonical/chisel/internal/archive" "github.com/canonical/chisel/internal/manifestutil" "github.com/canonical/chisel/internal/setup" @@ -120,7 +120,7 @@ var generateManifestTests = []struct { report *manifestutil.Report packageInfo []*archive.PackageInfo selection []*setup.Slice - expected *testutil.ManifestContents + expected *apachetestutil.ManifestContents error string }{{ summary: "Basic", @@ -155,7 +155,7 @@ var generateManifestTests = []struct { Arch: "a2", SHA256: "s2", }}, - expected: &testutil.ManifestContents{ + expected: &apachetestutil.ManifestContents{ Paths: []*manifest.Path{{ Kind: "path", Path: "/file", @@ -397,7 +397,7 @@ var generateManifestTests = []struct { Arch: "a1", SHA256: "s1", }}, - expected: &testutil.ManifestContents{ + expected: &apachetestutil.ManifestContents{ Paths: []*manifest.Path{{ Kind: "path", Path: "/file", @@ -553,7 +553,7 @@ func (s *S) TestGenerateManifests(c *C) { c.Assert(err, IsNil) err = manifest.Validate(mfest) c.Assert(err, IsNil) - contents := testutil.DumpManifestContents(c, mfest) + contents := apachetestutil.DumpManifestContents(c, mfest) c.Assert(contents, DeepEquals, test.expected) } } diff --git a/internal/setup/setup.go b/internal/setup/setup.go index 5c8070b7..e237e7f2 100644 --- a/internal/setup/setup.go +++ b/internal/setup/setup.go @@ -8,7 +8,7 @@ import ( "golang.org/x/crypto/openpgp/packet" - "github.com/canonical/chisel/internal/apache/util" + "github.com/canonical/chisel/internal/apacheutil" "github.com/canonical/chisel/internal/strdist" ) @@ -43,7 +43,7 @@ type Package struct { type Slice struct { Package string Name string - Essential []util.SliceKey + Essential []apacheutil.SliceKey Contents map[string]PathInfo Scripts SliceScripts } @@ -139,7 +139,7 @@ func ReadRelease(dir string) (*Release, error) { } func (r *Release) validate() error { - keys := []util.SliceKey(nil) + keys := []apacheutil.SliceKey(nil) // Check for info conflicts and prepare for following checks. A conflict // means that two slices attempt to extract different files or directories @@ -156,7 +156,7 @@ func (r *Release) validate() error { globs := make(map[string]*Slice) for _, pkg := range r.Packages { for _, new := range pkg.Slices { - keys = append(keys, util.SliceKey{pkg.Name, new.Name}) + keys = append(keys, apacheutil.SliceKey{pkg.Name, new.Name}) for newPath, newInfo := range new.Contents { if old, ok := paths[newPath]; ok { oldInfo := old.Contents[newPath] @@ -237,7 +237,7 @@ func (r *Release) validate() error { return nil } -func order(pkgs map[string]*Package, keys []util.SliceKey) ([]util.SliceKey, error) { +func order(pkgs map[string]*Package, keys []apacheutil.SliceKey) ([]apacheutil.SliceKey, error) { // Preprocess the list to improve error messages. for _, key := range keys { @@ -250,9 +250,9 @@ func order(pkgs map[string]*Package, keys []util.SliceKey) ([]util.SliceKey, err // Collect all relevant package slices. successors := map[string][]string{} - pending := append([]util.SliceKey(nil), keys...) + pending := append([]apacheutil.SliceKey(nil), keys...) - seen := make(map[util.SliceKey]bool) + seen := make(map[apacheutil.SliceKey]bool) for i := 0; i < len(pending); i++ { key := pending[i] if seen[key] { @@ -275,14 +275,14 @@ func order(pkgs map[string]*Package, keys []util.SliceKey) ([]util.SliceKey, err } // Sort them up. - var order []util.SliceKey + var order []apacheutil.SliceKey for _, names := range tarjanSort(successors) { if len(names) > 1 { return nil, fmt.Errorf("essential loop detected: %s", strings.Join(names, ", ")) } name := names[0] dot := strings.IndexByte(name, '_') - order = append(order, util.SliceKey{name[:dot], name[dot+1:]}) + order = append(order, apacheutil.SliceKey{name[:dot], name[dot+1:]}) } return order, nil @@ -323,7 +323,7 @@ func readSlices(release *Release, baseDir, dirName string) error { if entry.IsDir() || !strings.HasSuffix(entry.Name(), ".yaml") { continue } - match := util.FnameExp.FindStringSubmatch(entry.Name()) + match := apacheutil.FnameExp.FindStringSubmatch(entry.Name()) if match == nil { return fmt.Errorf("invalid slice definition filename: %q", entry.Name()) } @@ -354,7 +354,7 @@ func stripBase(baseDir, path string) string { return strings.TrimPrefix(path, baseDir+string(filepath.Separator)) } -func Select(release *Release, slices []util.SliceKey) (*Selection, error) { +func Select(release *Release, slices []apacheutil.SliceKey) (*Selection, error) { logf("Selecting slices...") selection := &Selection{ diff --git a/internal/setup/setup_test.go b/internal/setup/setup_test.go index 018ae065..26d537c7 100644 --- a/internal/setup/setup_test.go +++ b/internal/setup/setup_test.go @@ -9,7 +9,7 @@ import ( . "gopkg.in/check.v1" "gopkg.in/yaml.v3" - "github.com/canonical/chisel/internal/apache/util" + "github.com/canonical/chisel/internal/apacheutil" "github.com/canonical/chisel/internal/setup" "github.com/canonical/chisel/internal/testutil" ) @@ -24,7 +24,7 @@ type setupTest struct { input map[string]string release *setup.Release relerror string - selslices []util.SliceKey + selslices []apacheutil.SliceKey selection *setup.Selection selerror string } @@ -144,7 +144,7 @@ var setupTests = []setupTest{{ "myslice2": { Package: "mypkg", Name: "myslice2", - Essential: []util.SliceKey{ + Essential: []apacheutil.SliceKey{ {"mypkg", "myslice1"}, }, Contents: map[string]setup.PathInfo{ @@ -284,7 +284,7 @@ var setupTests = []setupTest{{ myslice2: {essential: [mypkg1_myslice1]} `, }, - selslices: []util.SliceKey{{"mypkg1", "myslice1"}}, + selslices: []apacheutil.SliceKey{{"mypkg1", "myslice1"}}, selection: &setup.Selection{ Slices: []*setup.Slice{{ Package: "mypkg1", @@ -307,7 +307,7 @@ var setupTests = []setupTest{{ myslice2: {essential: [mypkg1_myslice1]} `, }, - selslices: []util.SliceKey{{"mypkg2", "myslice2"}}, + selslices: []apacheutil.SliceKey{{"mypkg2", "myslice2"}}, selection: &setup.Selection{ Slices: []*setup.Slice{{ Package: "mypkg1", @@ -315,7 +315,7 @@ var setupTests = []setupTest{{ }, { Package: "mypkg2", Name: "myslice2", - Essential: []util.SliceKey{ + Essential: []apacheutil.SliceKey{ {"mypkg1", "myslice1"}, }, }}, @@ -346,7 +346,7 @@ var setupTests = []setupTest{{ /path3: {symlink: /link} `, }, - selslices: []util.SliceKey{{"mypkg1", "myslice1"}, {"mypkg1", "myslice2"}, {"mypkg2", "myslice1"}}, + selslices: []apacheutil.SliceKey{{"mypkg1", "myslice1"}, {"mypkg1", "myslice2"}, {"mypkg2", "myslice1"}}, }, { summary: "Conflicting paths across slices", input: map[string]string{ @@ -1200,7 +1200,7 @@ var setupTests = []setupTest{{ "slice1": { Package: "mypkg", Name: "slice1", - Essential: []util.SliceKey{ + Essential: []apacheutil.SliceKey{ {"mypkg", "slice2"}, }, }, @@ -1211,7 +1211,7 @@ var setupTests = []setupTest{{ "slice3": { Package: "mypkg", Name: "slice3", - Essential: []util.SliceKey{ + Essential: []apacheutil.SliceKey{ {"mypkg", "slice2"}, {"mypkg", "slice1"}, {"mypkg", "slice4"}, @@ -1220,7 +1220,7 @@ var setupTests = []setupTest{{ "slice4": { Package: "mypkg", Name: "slice4", - Essential: []util.SliceKey{ + Essential: []apacheutil.SliceKey{ {"mypkg", "slice2"}, }, }, @@ -1267,7 +1267,7 @@ var setupTests = []setupTest{{ "slice1": { Package: "mypkg", Name: "slice1", - Essential: []util.SliceKey{ + Essential: []apacheutil.SliceKey{ {"myotherpkg", "slice2"}, {"mypkg", "slice2"}, {"myotherpkg", "slice1"}, @@ -1276,7 +1276,7 @@ var setupTests = []setupTest{{ "slice2": { Package: "mypkg", Name: "slice2", - Essential: []util.SliceKey{ + Essential: []apacheutil.SliceKey{ {"myotherpkg", "slice2"}, }, }, @@ -1452,7 +1452,7 @@ var setupTests = []setupTest{{ }, }, }, - selslices: []util.SliceKey{{"mypkg", "myslice"}}, + selslices: []apacheutil.SliceKey{{"mypkg", "myslice"}}, selection: &setup.Selection{ Slices: []*setup.Slice{{ Package: "mypkg", @@ -1499,7 +1499,7 @@ var setupTests = []setupTest{{ }, }, }, - selslices: []util.SliceKey{{"mypkg", "myslice"}}, + selslices: []apacheutil.SliceKey{{"mypkg", "myslice"}}, selerror: `slice mypkg_myslice has invalid 'generate' for path /dir/\*\*: "foo"`, }, { summary: "Paths with generate: manifest must have trailing /**", diff --git a/internal/setup/yaml.go b/internal/setup/yaml.go index 2d37d10c..eb4ec0ea 100644 --- a/internal/setup/yaml.go +++ b/internal/setup/yaml.go @@ -10,7 +10,7 @@ import ( "golang.org/x/crypto/openpgp/packet" "gopkg.in/yaml.v3" - "github.com/canonical/chisel/internal/apache/util" + "github.com/canonical/chisel/internal/apacheutil" "github.com/canonical/chisel/internal/archive" "github.com/canonical/chisel/internal/deb" "github.com/canonical/chisel/internal/pgputil" @@ -304,7 +304,7 @@ func parsePackage(baseDir, pkgName, pkgPath string, data []byte) (*Package, erro zeroPath := yamlPath{} for sliceName, yamlSlice := range yamlPkg.Slices { - match := util.SnameExp.FindStringSubmatch(sliceName) + match := apacheutil.SnameExp.FindStringSubmatch(sliceName) if match == nil { return nil, fmt.Errorf("invalid slice name %q in %s", sliceName, pkgPath) } @@ -317,7 +317,7 @@ func parsePackage(baseDir, pkgName, pkgPath string, data []byte) (*Package, erro }, } for _, refName := range yamlPkg.Essential { - sliceKey, err := util.ParseSliceKey(refName) + sliceKey, err := apacheutil.ParseSliceKey(refName) if err != nil { return nil, fmt.Errorf("package %q has invalid essential slice reference: %q", pkgName, refName) } @@ -331,7 +331,7 @@ func parsePackage(baseDir, pkgName, pkgPath string, data []byte) (*Package, erro slice.Essential = append(slice.Essential, sliceKey) } for _, refName := range yamlSlice.Essential { - sliceKey, err := util.ParseSliceKey(refName) + sliceKey, err := apacheutil.ParseSliceKey(refName) if err != nil { return nil, fmt.Errorf("package %q has invalid essential slice reference: %q", pkgName, refName) } diff --git a/internal/slicer/slicer_test.go b/internal/slicer/slicer_test.go index 8545bdfa..0addac3c 100644 --- a/internal/slicer/slicer_test.go +++ b/internal/slicer/slicer_test.go @@ -14,7 +14,7 @@ import ( "github.com/klauspost/compress/zstd" . "gopkg.in/check.v1" - "github.com/canonical/chisel/internal/apache/util" + "github.com/canonical/chisel/internal/apacheutil" "github.com/canonical/chisel/internal/archive" "github.com/canonical/chisel/internal/setup" "github.com/canonical/chisel/internal/slicer" @@ -31,7 +31,7 @@ type slicerTest struct { arch string release map[string]string pkgs []*testutil.TestPackage - slices []util.SliceKey + slices []apacheutil.SliceKey hackopt func(c *C, opts *slicer.RunOptions) filesystem map[string]string manifestPaths map[string]string @@ -77,7 +77,7 @@ var testPackageCopyrightEntries = []testutil.TarEntry{ var slicerTests = []slicerTest{{ summary: "Basic slicing", - slices: []util.SliceKey{{"test-package", "myslice"}}, + slices: []apacheutil.SliceKey{{"test-package", "myslice"}}, release: map[string]string{ "slices/mydir/test-package.yaml": ` package: test-package @@ -110,7 +110,7 @@ var slicerTests = []slicerTest{{ }, }, { summary: "Glob extraction", - slices: []util.SliceKey{{"test-package", "myslice"}}, + slices: []apacheutil.SliceKey{{"test-package", "myslice"}}, release: map[string]string{ "slices/mydir/test-package.yaml": ` package: test-package @@ -132,7 +132,7 @@ var slicerTests = []slicerTest{{ }, }, { summary: "Create new file under extracted directory and preserve parent directory permissions", - slices: []util.SliceKey{{"test-package", "myslice"}}, + slices: []apacheutil.SliceKey{{"test-package", "myslice"}}, release: map[string]string{ "slices/mydir/test-package.yaml": ` package: test-package @@ -152,7 +152,7 @@ var slicerTests = []slicerTest{{ }, }, { summary: "Create new nested file under extracted directory and preserve parent directory permissions", - slices: []util.SliceKey{{"test-package", "myslice"}}, + slices: []apacheutil.SliceKey{{"test-package", "myslice"}}, release: map[string]string{ "slices/mydir/test-package.yaml": ` package: test-package @@ -173,7 +173,7 @@ var slicerTests = []slicerTest{{ }, }, { summary: "Create new directory under extracted directory and preserve parent directory permissions", - slices: []util.SliceKey{{"test-package", "myslice"}}, + slices: []apacheutil.SliceKey{{"test-package", "myslice"}}, release: map[string]string{ "slices/mydir/test-package.yaml": ` package: test-package @@ -193,7 +193,7 @@ var slicerTests = []slicerTest{{ }, }, { summary: "Create new file using glob and preserve parent directory permissions", - slices: []util.SliceKey{{"test-package", "myslice"}}, + slices: []apacheutil.SliceKey{{"test-package", "myslice"}}, release: map[string]string{ "slices/mydir/test-package.yaml": ` package: test-package @@ -217,7 +217,7 @@ var slicerTests = []slicerTest{{ }, { summary: "Conditional architecture", arch: "amd64", - slices: []util.SliceKey{{"test-package", "myslice"}}, + slices: []apacheutil.SliceKey{{"test-package", "myslice"}}, release: map[string]string{ "slices/mydir/test-package.yaml": ` package: test-package @@ -248,7 +248,7 @@ var slicerTests = []slicerTest{{ }, }, { summary: "Copyright is not installed implicitly", - slices: []util.SliceKey{{"test-package", "myslice"}}, + slices: []apacheutil.SliceKey{{"test-package", "myslice"}}, pkgs: []*testutil.TestPackage{{ Name: "test-package", // Add the copyright entries to the package. @@ -272,7 +272,7 @@ var slicerTests = []slicerTest{{ }, }, { summary: "Install two packages", - slices: []util.SliceKey{ + slices: []apacheutil.SliceKey{ {"test-package", "myslice"}, {"other-package", "myslice"}}, pkgs: []*testutil.TestPackage{{ @@ -315,7 +315,7 @@ var slicerTests = []slicerTest{{ }, }, { summary: "Install two packages, explicit path has preference over implicit parent", - slices: []util.SliceKey{ + slices: []apacheutil.SliceKey{ {"a-implicit-parent", "myslice"}, {"b-explicit-dir", "myslice"}, {"c-implicit-parent", "myslice"}}, @@ -372,7 +372,7 @@ var slicerTests = []slicerTest{{ }, }, { summary: "Valid same file in two slices in different packages", - slices: []util.SliceKey{ + slices: []apacheutil.SliceKey{ {"test-package", "myslice"}, {"other-package", "myslice"}}, pkgs: []*testutil.TestPackage{{ @@ -406,7 +406,7 @@ var slicerTests = []slicerTest{{ }, }, { summary: "Script: write a file", - slices: []util.SliceKey{{"test-package", "myslice"}}, + slices: []apacheutil.SliceKey{{"test-package", "myslice"}}, release: map[string]string{ "slices/mydir/test-package.yaml": ` package: test-package @@ -427,7 +427,7 @@ var slicerTests = []slicerTest{{ }, }, { summary: "Script: read a file", - slices: []util.SliceKey{{"test-package", "myslice"}}, + slices: []apacheutil.SliceKey{{"test-package", "myslice"}}, release: map[string]string{ "slices/mydir/test-package.yaml": ` package: test-package @@ -453,7 +453,7 @@ var slicerTests = []slicerTest{{ }, }, { summary: "Script: use 'until' to remove file after mutate", - slices: []util.SliceKey{{"test-package", "myslice"}}, + slices: []apacheutil.SliceKey{{"test-package", "myslice"}}, release: map[string]string{ "slices/mydir/test-package.yaml": ` package: test-package @@ -477,7 +477,7 @@ var slicerTests = []slicerTest{{ }, }, { summary: "Script: use 'until' to remove wildcard after mutate", - slices: []util.SliceKey{{"test-package", "myslice"}}, + slices: []apacheutil.SliceKey{{"test-package", "myslice"}}, release: map[string]string{ "slices/mydir/test-package.yaml": ` package: test-package @@ -495,7 +495,7 @@ var slicerTests = []slicerTest{{ manifestPaths: map[string]string{}, }, { summary: "Script: 'until' does not remove non-empty directories", - slices: []util.SliceKey{{"test-package", "myslice"}}, + slices: []apacheutil.SliceKey{{"test-package", "myslice"}}, release: map[string]string{ "slices/mydir/test-package.yaml": ` package: test-package @@ -516,7 +516,7 @@ var slicerTests = []slicerTest{{ }, }, { summary: "Script: writing same contents to existing file does not set the final hash in report", - slices: []util.SliceKey{{"test-package", "myslice"}}, + slices: []apacheutil.SliceKey{{"test-package", "myslice"}}, release: map[string]string{ "slices/mydir/test-package.yaml": ` package: test-package @@ -537,7 +537,7 @@ var slicerTests = []slicerTest{{ }, }, { summary: "Script: cannot write non-mutable files", - slices: []util.SliceKey{{"test-package", "myslice"}}, + slices: []apacheutil.SliceKey{{"test-package", "myslice"}}, release: map[string]string{ "slices/mydir/test-package.yaml": ` package: test-package @@ -552,7 +552,7 @@ var slicerTests = []slicerTest{{ error: `slice test-package_myslice: cannot write file which is not mutable: /dir/text-file`, }, { summary: "Script: cannot write to unlisted file", - slices: []util.SliceKey{{"test-package", "myslice"}}, + slices: []apacheutil.SliceKey{{"test-package", "myslice"}}, release: map[string]string{ "slices/mydir/test-package.yaml": ` package: test-package @@ -566,7 +566,7 @@ var slicerTests = []slicerTest{{ error: `slice test-package_myslice: cannot write file which is not mutable: /dir/text-file`, }, { summary: "Script: cannot write to directory", - slices: []util.SliceKey{{"test-package", "myslice"}}, + slices: []apacheutil.SliceKey{{"test-package", "myslice"}}, release: map[string]string{ "slices/mydir/test-package.yaml": ` package: test-package @@ -581,7 +581,7 @@ var slicerTests = []slicerTest{{ error: `slice test-package_myslice: cannot write file which is not mutable: /dir/`, }, { summary: "Script: cannot read unlisted content", - slices: []util.SliceKey{{"test-package", "myslice2"}}, + slices: []apacheutil.SliceKey{{"test-package", "myslice2"}}, release: map[string]string{ "slices/mydir/test-package.yaml": ` package: test-package @@ -597,7 +597,7 @@ var slicerTests = []slicerTest{{ error: `slice test-package_myslice2: cannot read file which is not selected: /dir/text-file`, }, { summary: "Script: can read globbed content", - slices: []util.SliceKey{{"test-package", "myslice1"}, {"test-package", "myslice2"}}, + slices: []apacheutil.SliceKey{{"test-package", "myslice1"}, {"test-package", "myslice2"}}, release: map[string]string{ "slices/mydir/test-package.yaml": ` package: test-package @@ -612,7 +612,7 @@ var slicerTests = []slicerTest{{ }, }, { summary: "Relative content root directory must not error", - slices: []util.SliceKey{{"test-package", "myslice"}}, + slices: []apacheutil.SliceKey{{"test-package", "myslice"}}, release: map[string]string{ "slices/mydir/test-package.yaml": ` package: test-package @@ -633,7 +633,7 @@ var slicerTests = []slicerTest{{ }, }, { summary: "Can list parent directories of normal paths", - slices: []util.SliceKey{{"test-package", "myslice"}}, + slices: []apacheutil.SliceKey{{"test-package", "myslice"}}, release: map[string]string{ "slices/mydir/test-package.yaml": ` package: test-package @@ -652,7 +652,7 @@ var slicerTests = []slicerTest{{ }, }, { summary: "Cannot list unselected directory", - slices: []util.SliceKey{{"test-package", "myslice"}}, + slices: []apacheutil.SliceKey{{"test-package", "myslice"}}, release: map[string]string{ "slices/mydir/test-package.yaml": ` package: test-package @@ -667,7 +667,7 @@ var slicerTests = []slicerTest{{ error: `slice test-package_myslice: cannot list directory which is not selected: /a/d/`, }, { summary: "Cannot list file path as a directory", - slices: []util.SliceKey{{"test-package", "myslice"}}, + slices: []apacheutil.SliceKey{{"test-package", "myslice"}}, release: map[string]string{ "slices/mydir/test-package.yaml": ` package: test-package @@ -682,7 +682,7 @@ var slicerTests = []slicerTest{{ error: `slice test-package_myslice: content is not a directory: /a/b/c`, }, { summary: "Can list parent directories of globs", - slices: []util.SliceKey{{"test-package", "myslice"}}, + slices: []apacheutil.SliceKey{{"test-package", "myslice"}}, release: map[string]string{ "slices/mydir/test-package.yaml": ` package: test-package @@ -696,7 +696,7 @@ var slicerTests = []slicerTest{{ }, }, { summary: "Cannot list directories not matched by glob", - slices: []util.SliceKey{{"test-package", "myslice"}}, + slices: []apacheutil.SliceKey{{"test-package", "myslice"}}, release: map[string]string{ "slices/mydir/test-package.yaml": ` package: test-package @@ -711,7 +711,7 @@ var slicerTests = []slicerTest{{ error: `slice test-package_myslice: cannot list directory which is not selected: /other-dir/`, }, { summary: "Duplicate copyright symlink is ignored", - slices: []util.SliceKey{{"copyright-symlink-openssl", "bins"}}, + slices: []apacheutil.SliceKey{{"copyright-symlink-openssl", "bins"}}, pkgs: []*testutil.TestPackage{{ Name: "copyright-symlink-openssl", Data: testutil.MustMakeDeb(packageEntries["copyright-symlink-openssl"]), @@ -743,7 +743,7 @@ var slicerTests = []slicerTest{{ }, }, { summary: "Can list unclean directory paths", - slices: []util.SliceKey{{"test-package", "myslice"}}, + slices: []apacheutil.SliceKey{{"test-package", "myslice"}}, release: map[string]string{ "slices/mydir/test-package.yaml": ` package: test-package @@ -762,7 +762,7 @@ var slicerTests = []slicerTest{{ }, }, { summary: "Cannot read directories", - slices: []util.SliceKey{{"test-package", "myslice"}}, + slices: []apacheutil.SliceKey{{"test-package", "myslice"}}, release: map[string]string{ "slices/mydir/test-package.yaml": ` package: test-package @@ -777,7 +777,7 @@ var slicerTests = []slicerTest{{ error: `slice test-package_myslice: content is not a file: /x/y`, }, { summary: "Multiple archives with priority", - slices: []util.SliceKey{{"test-package", "myslice"}, {"other-package", "myslice"}}, + slices: []apacheutil.SliceKey{{"test-package", "myslice"}, {"other-package", "myslice"}}, pkgs: []*testutil.TestPackage{{ Name: "test-package", Hash: "h1", @@ -858,7 +858,7 @@ var slicerTests = []slicerTest{{ }, }, { summary: "Pinned archive bypasses higher priority", - slices: []util.SliceKey{{"test-package", "myslice"}}, + slices: []apacheutil.SliceKey{{"test-package", "myslice"}}, pkgs: []*testutil.TestPackage{{ Name: "test-package", Hash: "h1", @@ -923,7 +923,7 @@ var slicerTests = []slicerTest{{ }, }, { summary: "Pinned archive does not have the package", - slices: []util.SliceKey{{"test-package", "myslice"}}, + slices: []apacheutil.SliceKey{{"test-package", "myslice"}}, pkgs: []*testutil.TestPackage{{ Name: "test-package", Data: testutil.MustMakeDeb([]testutil.TarEntry{ @@ -966,7 +966,7 @@ var slicerTests = []slicerTest{{ error: `cannot find package "test-package" in archive\(s\)`, }, { summary: "No archives have the package", - slices: []util.SliceKey{{"test-package", "myslice"}}, + slices: []apacheutil.SliceKey{{"test-package", "myslice"}}, pkgs: []*testutil.TestPackage{}, release: map[string]string{ "chisel.yaml": ` @@ -1000,7 +1000,7 @@ var slicerTests = []slicerTest{{ error: `cannot find package "test-package" in archive\(s\)`, }, { summary: "Negative priority archives are ignored when not explicitly pinned in package", - slices: []util.SliceKey{{"test-package", "myslice"}}, + slices: []apacheutil.SliceKey{{"test-package", "myslice"}}, pkgs: []*testutil.TestPackage{{ Name: "test-package", Data: testutil.MustMakeDeb([]testutil.TarEntry{ @@ -1034,7 +1034,7 @@ var slicerTests = []slicerTest{{ error: `cannot find package "test-package" in archive\(s\)`, }, { summary: "Negative priority archive explicitly pinned in package", - slices: []util.SliceKey{{"test-package", "myslice"}}, + slices: []apacheutil.SliceKey{{"test-package", "myslice"}}, pkgs: []*testutil.TestPackage{{ Name: "test-package", Hash: "h1", @@ -1080,7 +1080,7 @@ var slicerTests = []slicerTest{{ }, }, { summary: "Multiple slices of same package", - slices: []util.SliceKey{ + slices: []apacheutil.SliceKey{ {"test-package", "myslice1"}, {"test-package", "myslice2"}, }, @@ -1118,7 +1118,7 @@ var slicerTests = []slicerTest{{ }, }, { summary: "Same glob in several entries with until:mutate and reading from script", - slices: []util.SliceKey{ + slices: []apacheutil.SliceKey{ {"test-package", "myslice1"}, {"test-package", "myslice2"}, }, @@ -1164,7 +1164,7 @@ var slicerTests = []slicerTest{{ }, }, { summary: "Overlapping globs, until:mutate and reading from script", - slices: []util.SliceKey{ + slices: []apacheutil.SliceKey{ {"test-package", "myslice2"}, {"test-package", "myslice1"}, }, @@ -1210,7 +1210,7 @@ var slicerTests = []slicerTest{{ }, }, { summary: "Overlapping glob and single entry, until:mutate on entry and reading from script", - slices: []util.SliceKey{ + slices: []apacheutil.SliceKey{ {"test-package", "myslice1"}, {"test-package", "myslice2"}, }, @@ -1256,7 +1256,7 @@ var slicerTests = []slicerTest{{ }, }, { summary: "Overlapping glob and single entry, until:mutate on glob and reading from script", - slices: []util.SliceKey{ + slices: []apacheutil.SliceKey{ {"test-package", "myslice1"}, {"test-package", "myslice2"}, }, @@ -1285,7 +1285,7 @@ var slicerTests = []slicerTest{{ }, }, { summary: "Overlapping glob and single entry, until:mutate on both and reading from script", - slices: []util.SliceKey{ + slices: []apacheutil.SliceKey{ {"test-package", "myslice1"}, {"test-package", "myslice2"}, }, @@ -1309,7 +1309,7 @@ var slicerTests = []slicerTest{{ manifestPaths: map[string]string{}, }, { summary: "Content not created in packages with until:mutate on one and reading from script", - slices: []util.SliceKey{ + slices: []apacheutil.SliceKey{ {"test-package", "myslice1"}, {"test-package", "myslice2"}, }, @@ -1333,7 +1333,7 @@ var slicerTests = []slicerTest{{ manifestPaths: map[string]string{"/file": "file 0644 2c26b46b {test-package_myslice1,test-package_myslice2}"}, }, { summary: "Install two packages, both are recorded", - slices: []util.SliceKey{ + slices: []apacheutil.SliceKey{ {"test-package", "myslice"}, {"other-package", "myslice"}, }, @@ -1370,7 +1370,7 @@ var slicerTests = []slicerTest{{ }, }, { summary: "Two packages, only one is selected and recorded", - slices: []util.SliceKey{ + slices: []apacheutil.SliceKey{ {"test-package", "myslice"}, }, pkgs: []*testutil.TestPackage{{ @@ -1405,7 +1405,7 @@ var slicerTests = []slicerTest{{ }, }, { summary: "Relative paths are properly trimmed during extraction", - slices: []util.SliceKey{{"test-package", "myslice"}}, + slices: []apacheutil.SliceKey{{"test-package", "myslice"}}, pkgs: []*testutil.TestPackage{{ Name: "test-package", Data: testutil.MustMakeDeb([]testutil.TarEntry{ @@ -1436,7 +1436,7 @@ var slicerTests = []slicerTest{{ }, }, { summary: "Producing a manifest is not mandatory", - slices: []util.SliceKey{{"test-package", "myslice"}}, + slices: []apacheutil.SliceKey{{"test-package", "myslice"}}, hackopt: func(c *C, opts *slicer.RunOptions) { // Remove the manifest slice that the tests add automatically. var index int @@ -1458,7 +1458,7 @@ var slicerTests = []slicerTest{{ }, }, { summary: "No valid archives defined due to invalid pro value", - slices: []util.SliceKey{{"test-package", "myslice"}}, + slices: []apacheutil.SliceKey{{"test-package", "myslice"}}, release: map[string]string{ "chisel.yaml": ` format: v1 @@ -1481,7 +1481,7 @@ var slicerTests = []slicerTest{{ error: `cannot find package "test-package" in archive\(s\)`, }, { summary: "Valid hard link in two slices in the same package", - slices: []util.SliceKey{ + slices: []apacheutil.SliceKey{ {"test-package", "slice1"}, {"test-package", "slice2"}}, pkgs: []*testutil.TestPackage{{ @@ -1515,7 +1515,7 @@ var slicerTests = []slicerTest{{ }, }, { summary: "Hard link entries can be extracted without extracting the regular file", - slices: []util.SliceKey{ + slices: []apacheutil.SliceKey{ {"test-package", "myslice"}}, pkgs: []*testutil.TestPackage{{ Name: "test-package", @@ -1545,7 +1545,7 @@ var slicerTests = []slicerTest{{ }, }, { summary: "Hard link identifier for different groups", - slices: []util.SliceKey{ + slices: []apacheutil.SliceKey{ {"test-package", "myslice"}}, pkgs: []*testutil.TestPackage{{ Name: "test-package", @@ -1580,7 +1580,7 @@ var slicerTests = []slicerTest{{ }, }, { summary: "Single hard link entry can be extracted without regular file and no hard links are created", - slices: []util.SliceKey{ + slices: []apacheutil.SliceKey{ {"test-package", "myslice"}}, pkgs: []*testutil.TestPackage{{ Name: "test-package", @@ -1607,7 +1607,7 @@ var slicerTests = []slicerTest{{ }, }, { summary: "Hard link to symlink does not follow symlink", - slices: []util.SliceKey{ + slices: []apacheutil.SliceKey{ {"test-package", "myslice"}}, pkgs: []*testutil.TestPackage{{ Name: "test-package", @@ -1639,7 +1639,7 @@ var slicerTests = []slicerTest{{ }, }, { summary: "Hard link identifiers are unique across packages", - slices: []util.SliceKey{ + slices: []apacheutil.SliceKey{ {"test-package1", "myslice"}, {"test-package2", "myslice"}, }, @@ -1690,7 +1690,7 @@ var slicerTests = []slicerTest{{ }, }, { summary: "Mutations for hard links are forbidden", - slices: []util.SliceKey{ + slices: []apacheutil.SliceKey{ {"test-package", "myslice"}}, pkgs: []*testutil.TestPackage{{ Name: "test-package", @@ -1715,7 +1715,7 @@ var slicerTests = []slicerTest{{ error: `slice test-package_myslice: cannot mutate a hard link: /hardlink`, }, { summary: "Hard links can be marked as mutable, but not mutated", - slices: []util.SliceKey{ + slices: []apacheutil.SliceKey{ {"test-package", "myslice"}}, pkgs: []*testutil.TestPackage{{ Name: "test-package", @@ -1833,7 +1833,7 @@ func runSlicerTests(c *C, tests []slicerTest) { }, Scripts: setup.SliceScripts{}, } - testSlices = append(testSlices, util.SliceKey{ + testSlices = append(testSlices, apacheutil.SliceKey{ Package: manifestPackage, Slice: "manifest", }) diff --git a/pkg/manifest/manifest.go b/pkg/manifest/manifest.go index 7ee39de4..628461c5 100644 --- a/pkg/manifest/manifest.go +++ b/pkg/manifest/manifest.go @@ -7,7 +7,7 @@ import ( "io" "slices" - "github.com/canonical/chisel/internal/apache/util" + "github.com/canonical/chisel/internal/apacheutil" "github.com/canonical/chisel/pkg/jsonwall" ) @@ -107,7 +107,7 @@ func Validate(manifest *Manifest) (err error) { sliceExist := map[string]bool{} err = manifest.IterateSlices("", func(slice *Slice) error { - sk, err := util.ParseSliceKey(slice.Name) + sk, err := apacheutil.ParseSliceKey(slice.Name) if err != nil { return err } diff --git a/pkg/manifest/manifest_test.go b/pkg/manifest/manifest_test.go index f91a33bf..537d328e 100644 --- a/pkg/manifest/manifest_test.go +++ b/pkg/manifest/manifest_test.go @@ -10,14 +10,14 @@ import ( . "gopkg.in/check.v1" - "github.com/canonical/chisel/internal/apache/testutil" + "github.com/canonical/chisel/internal/apachetestutil" "github.com/canonical/chisel/pkg/manifest" ) var readManifestTests = []struct { summary string input string - mfest *testutil.ManifestContents + mfest *apachetestutil.ManifestContents valError string readError string }{{ @@ -43,7 +43,7 @@ var readManifestTests = []struct { {"kind":"slice","name":"pkg1_myslice"} {"kind":"slice","name":"pkg2_myotherslice"} `, - mfest: &testutil.ManifestContents{ + mfest: &apachetestutil.ManifestContents{ Paths: []*manifest.Path{ {Kind: "path", Path: "/dir/file", Mode: "0644", Slices: []string{"pkg1_myslice"}, SHA256: "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", FinalSHA256: "8067926c032c090867013d14fb0eb21ae858344f62ad07086fd32375845c91a6", Size: 0x15, Link: ""}, {Kind: "path", Path: "/dir/file2", Mode: "0644", Slices: []string{"pkg1_myslice"}, SHA256: "b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c", Size: 0x03, Link: "", Inode: 0x01}, @@ -168,7 +168,7 @@ func (s *S) TestManifestReadValidate(c *C) { } c.Assert(err, IsNil) if test.mfest != nil { - c.Assert(testutil.DumpManifestContents(c, mfest), DeepEquals, test.mfest) + c.Assert(apachetestutil.DumpManifestContents(c, mfest), DeepEquals, test.mfest) } } }