Skip to content

Commit

Permalink
change package names to apache
Browse files Browse the repository at this point in the history
  • Loading branch information
letFunny committed Jan 17, 2025
1 parent 3fe73cb commit 305c014
Show file tree
Hide file tree
Showing 14 changed files with 129 additions and 129 deletions.
6 changes: 3 additions & 3 deletions cmd/chisel/cmd_cut.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/chisel/cmd_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: Apache-2.0

package testutil
package apachetestutil

import (
"gopkg.in/check.v1"
Expand Down
2 changes: 1 addition & 1 deletion internal/apache/util/log.go → internal/apacheutil/log.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: Apache-2.0

package util
package apacheutil

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -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) }
Expand All @@ -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)
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: Apache-2.0

package util
package apacheutil

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -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"`,
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions internal/manifestutil/manifestutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -155,7 +155,7 @@ var generateManifestTests = []struct {
Arch: "a2",
SHA256: "s2",
}},
expected: &testutil.ManifestContents{
expected: &apachetestutil.ManifestContents{
Paths: []*manifest.Path{{
Kind: "path",
Path: "/file",
Expand Down Expand Up @@ -397,7 +397,7 @@ var generateManifestTests = []struct {
Arch: "a1",
SHA256: "s1",
}},
expected: &testutil.ManifestContents{
expected: &apachetestutil.ManifestContents{
Paths: []*manifest.Path{{
Kind: "path",
Path: "/file",
Expand Down Expand Up @@ -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)
}
}
Expand Down
22 changes: 11 additions & 11 deletions internal/setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand All @@ -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]
Expand Down Expand Up @@ -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 {
Expand All @@ -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] {
Expand All @@ -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
Expand Down Expand Up @@ -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())
}
Expand Down Expand Up @@ -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{
Expand Down
Loading

0 comments on commit 305c014

Please sign in to comment.